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.
IndexProgramming Questions & HelpOther Libraries › Exporting to PDF problem
Page Index Toggle Pages: 1
Exporting to PDF problem (Read 1391 times)
Exporting to PDF problem
May 28th, 2007, 6:19pm
 
Hi

I've only been using Processing for a few weeks so am still grasping the basics. I have searched the site but cannot find any info on my problem. I haven't posted here before so sorry if this comes across as a silly question.

I'm trying to output to either a .PDF or .SVG file (I've tried both) but cannot get the results I'm after.

I'm using the Sonia library to control various parameters in my drawing method and leave a trail on the screen. I'm creating the trail by not refreshing the background as crudely demonstrated below:

void draw() {
   
//background(0);

drawing stuff goes here;

}

The problem lies in that my PDFs are not cumulative - that is they aren't an accurate reflection of what is on the screen. They only show the drawing data for the corresponding frame.

Does anybody know where I am going wrong or have any suggestions as to how I can output a cumulative series of PDFs?

Thanks a lot

Michael
Re: Exporting to PDF problem
Reply #1 - May 28th, 2007, 6:38pm
 
How are you outputting to PDF? Are you using size(600,400,PDF,"filename"); or beginRecord()/endRecord?

You probably want to set it up so that you start recording at frame 0, but don't end until you press a key or something.
Re: Exporting to PDF problem
Reply #2 - May 28th, 2007, 7:34pm
 
Hi John thanks for the quick reply.

I have tried the beginRecord/endRecord method. It works with some success. I can output a strange, almost animated PDF but alas I cannot open it with any of my Adobe software without it crashing them.

I've since been trying to figure out a way to use Christian Riekoff's proSVG library. I have no problem exporting single frame data. I thought that maybe if I used

save("test-####.svg");

instead of

saveFrame("test-####.svg");

I'd be able to cheat the program into filling the file with all the vector data but sadly not. Smiley

Do you think if I took the save("test-####.svg"); out of the draw() function it would save all the data to one file?

Sadly I am not a programmer, merely a designer who has stumbled into this fascinating world so I'm not that great at the syntax yet. Any more help is greatly appreciated!


Re: Exporting to PDF problem
Reply #3 - May 28th, 2007, 8:30pm
 
Ah.. if it is loading then crashing in adobe, then I suspect you're just trying to put far too much data into your PDF. Since every shape is written out longhand into the PDF, it doesn't know "oh that shape is completely obscured by the time everything's drawn, ignore it", it'll try to have every single shape in memory at the same time, which, with a lot of shapes, could be far too many, and cause it to crash.

The "animated" PDf effect, is just it loading the shapes in order, ad drawing them as it loads them.. so you can see just how much data it's trying to handle.
Re: Exporting to PDF problem
Reply #4 - May 28th, 2007, 9:50pm
 
I see, so my array of 1000 particles isn't doing any favours in this instance! Smiley

Thanks for the explanation I'll keep trying.
Re: Exporting to PDF problem
Reply #5 - May 28th, 2007, 11:49pm
 
If you've got Adobe Acrobat Distiller you could try to process, convert, optimize the PDF file before opening it in Acrobat Reader.

Distiller just processes the file in the background. Could be worth a try.
Re: Exporting to PDF problem
Reply #6 - May 28th, 2007, 11:54pm
 
Thanks for that I'll give it a go. Managed to come up with a temporary fix using proSVG. I've set it up so that when I click the mouse it takes a vector 'photo' of that particular screen. It's slow and clunky but I'll have to live with it until I find another way.
Re: Exporting to PDF problem
Reply #7 - May 29th, 2007, 12:27am
 
Here's a program that starts saving shapes to a pdf when the mouse button is pressed and it finishes the file when the mouse is released. It saves each frame between the press and release to the pdf. I think this is similar to what you want to do. There is a limit, though, to how much vector data you can write to one pdf file.

Casey


Quote:

import processing.pdf.*;

void setup() {
 size(600, 600);
 frameRate(24);
 background(255);
}

void draw() {
 stroke(0, 20);
 strokeWeight(20.0);
 line(mouseX, 0, width-mouseY, height);
}

void mousePressed() {
 beginRecord(PDF, "Lines.pdf");
 background(255);
}

void mouseReleased() {
 endRecord();
 background(255);
}
Re: Exporting to PDF problem
Reply #8 - May 29th, 2007, 10:28am
 
Thanks for the program Casey. It is still only saving one frame at a time though,  This might have something to do with my processor, I'm not too sure. When I have a cleaner version of the proSVG thing working I'll post it up. Thanks for the input everyone. Smiley
Page Index Toggle Pages: 1