We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
PDF and PImage (Read 418 times)
PDF and PImage
Jun 14th, 2008, 12:23am
 
i have a processing sketch in which i work with several images and their transparency. when pressing 'S' i want to save the current screen to a pdf using this code:

void doPDF()
{
 beginRecord(PDF,"myfile.pdf");
 background(0)
 endRecord();
}

i just get a black screen saved as pdf without the images i see in my applet?
is there any  trouble using images and saving them to a pdf?
i tried to use the same script and just drew circles to my screen and then used the save-to-pdf-function. that worked quite well. so i came to the point that there must be trouble with images (png - files) and the pdf.

i'm glad for any help
Re: PDF and PImage
Reply #1 - Jun 14th, 2008, 1:08am
 
Not sure if you took a look at the PDF library:

http://processing.org/reference/libraries/pdf/index.html

Maybe you need to incorporate import processing.pdf.*;
Re: PDF and PImage
Reply #2 - Jun 14th, 2008, 8:34am
 
Well, your code snippet just writes a black screen (the background(0) instruction) to PDF, so you get what you put there.
Re: PDF and PImage
Reply #3 - Jun 14th, 2008, 1:22pm
 
i deleted the background (0) line and i now get a white pdf but it does not show anything...
so i changed it back to black and i just put some squares on the screen. works perfectly well..
i try to figure out whats going wrong with the images...
Re: PDF and PImage
Reply #4 - Jun 14th, 2008, 1:56pm
 
Did you looked at the reference page pointed out above?
To summarize, you need to call beginRecord() when pressing S, setting up a flag telling your started to record.
Next call on draw() will draw on screen and in the PDF file, and at the end of draw(), call, if the flag is set, endRecord() and reset the flag.

I might try and do a bit of code to illustrate this better if you need, I haven't tried this library yet.
Page Index Toggle Pages: 1