Print Page | Close Window

Create image file but retain pdf transparency

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3771
Printed Date: 26 Apr 24 at 9:35AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Create image file but retain pdf transparency
Posted By: bbenc
Subject: Create image file but retain pdf transparency
Date Posted: 20 Dec 19 at 6:40AM
Hello, I have just found this amazing sdk but I am having some difficulties with creating image files from PDF.
I can create a pdf and load an image to it with transparency (basic outline of code below)  
Call objPDF.LoadFromFile(strPDFFolder & "\" & strPDFFile, "")
dblImageID = objPDF.AddImageFromFile(strWMFolder & "\" & strWMFile, 0)
objPDF.NormalizePage (0)
objPDF.SetOrigin (1)
dblContentStream = objPDF.NewContentStream
objPDF.SelectContentStream (dblContentStream)
objPDF.SaveState
objPDF.SetTransparency (dblTransparency)
objPDF.SelectImage (dblImageID)
Call objPDF.DrawImage(0, 0, objPDF.PageWidth, objPDF.PageHeight)
objPDF.LoadState
Call objPDF.MoveContentStream(dblContentStream, IIf(blnLayerZero = True, 0, objPDF.ContentStreamCount + 1))
objPDF.SaveToFile (strPDFFolderNew & "\" & strPDFFileNew)

This applies an image to the PDF and sets it transparency perfectly, but when generating the image file the actual image I applied to the PDF is the only thing I see in the image file, so the transparency setting I applied is being ignored and set at 100 (assuming). 

Is there any way to create the image file that retains the transparency we apply to the PDF?

Thanks,

Benjamin



Replies:
Posted By: bbenc
Date Posted: 20 Dec 19 at 6:43AM
oh, sorry, forgot to add. I am using the following code to generate the image file:
Call objPDF.RenderDocumentToFile(dblDPI, 1, dblPages, 0, strPDFFolder & "\" & strImageFile & "." & strImageFileExt)
Ive also tried the DARenderToPage with the same results.
I am using version 17 activeX or DLL.


Posted By: Ingo
Date Posted: 20 Dec 19 at 11:03AM
Hi Benjamin,

did you do the rendering right after the save?
Try it after a new load...

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: bbenc
Date Posted: 20 Dec 19 at 2:40PM
Thankyou for the reply Ingo, but unfortunately that didn't work for me (as that's what I was doing), but thought I might try the render immediately (ie: before the save to pdf) but unfortunately that didn't work either.
My code is written modularly, so the first module combines the images, saves them as a pdf, and releases the object. The next module does a fresh load of the saved file and renders to image.
I was thinking the layers weren't supported by jpg, so I tried gif/tif/png...all 10 supported file formats and still get the same result...The semi transparent image becomes 0% transparent (fully displayed) in the image file.
The test image file I am using (as the transparent layer) has a white background. Maybe I could try and overlay an image without a background layer. I'm really not sure what else to try.


Posted By: bbenc
Date Posted: 20 Dec 19 at 2:50PM
Just tried a "background-less" image, but when its put into the pdf, it masks the "missing" background with white. The render to image retains that white background.


Posted By: bbenc
Date Posted: 20 Dec 19 at 3:00PM
Ok, so I just tried to apply transparent text to a pdf and then render it to an image and it worked perfectly, so not sure why the transparent image is not co-operating.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk