Loading...

Background color of pdf

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Background color of pdf

Postby heard » Mon Oct 19, 2009 7:27 pm

Hi Loic,
Is there a way to set the background color of a pdf to white? This is related to my previous question about background color. I'm trying to create a new image with white background, then draw part of an existing image into it. I got this to work fine but now I want to take the newly created image and save it as a pdf. If I create the page in the pdf and draw the image into it, the background is black, not white.

Thanks,
Heard
heard
 
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Background color of pdf

Postby Loïc » Tue Oct 20, 2009 10:45 am

Hi Heard,

I don't understand you.

Please, provide code snippet, detailed explanations and attach your resulting PDF.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Background color of pdf

Postby heard » Tue Oct 20, 2009 3:51 pm

Hi Loic,
Let's say we have a standard 8.5x11 page.

Code: Select all
pic_ID=gdpic.createimagefromfile('c:\test.tif')

I want to take the top 2" and save as a pdf, but I want the pdf to be 8.5x11 with white background.
First create a new image with a white background:

Code: Select all
gdpic.SetVerticalResolution(300)
gdpic.SetHorizontalResolution(300)
pic2_ID=gdpic.CreateNewImage(2550,3300,32,16777215)
gdpic.DrawImage(pic1_ID,0,0,2550,600) 'Draw only 2".


Now I want to save it as a pdf. I want the pdf page to also be 8.5x11 but I don't want the remaining 6.5 inches to be black. I want it to be white.

Code: Select all
gdpic.PdfNewPdf('c:\test.pdf')
gdpic.pdfSetMeasurementUnits(3)
gdpic.PdfAddImageFromGDpictureImage(pic2_ID)
gdpic.PdfSetPageDimensions(8.5,11)
gdpic.PdfNewPage
gdpic.PdfDrawImage(1,0,0,8.5,11)
gdpic.PdfEndPage
gdpic.PdfSavePdf


If you do this, the background of the pdf is black, not white. There must be an easier way to do this.


Thanks,
Heard
Attachments
test.zip
(277.09 KiB) Downloaded 33 times
heard
 
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Background color of pdf

Postby Loïc » Tue Oct 20, 2009 3:57 pm

Heard, you have a black background because you are creating a bitmap with a black background.

Just replace

Code: Select all
pic2_ID=gdpic.CreateNewImage(2550,3300,32,16777215)


by:

Code: Select all
pic2_ID=gdpic.CreateNewImage(2550,3300,32,gdpic.ARGB(255,255,255,255))



Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Background color of pdf

Postby heard » Tue Oct 20, 2009 4:17 pm

Thank you, Loic!!

Does the new download take care of my PrintImageDialog issue?

Regards,
Heard
heard
 
Posts: 78
Joined: Wed Jan 02, 2008 11:55 pm

Re: Background color of pdf

Postby Loïc » Tue Oct 20, 2009 4:19 pm

Yes ! :D
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron