Hey processing community,
is it possible to export 2 files at the same time for web and print?
Thanks a lot in advance,
Hey processing community,
is it possible to export 2 files at the same time for web and print?
Thanks a lot in advance,
Hi @res56 ,
Can you give more details on “web” and “print”?
If you mean svg
/ pdf
or png
/ jpg
, yes it’s possible :
For print pdf would be perfect. For web png/jpg.
At the moment I only get an image with saveFrame(“balls-#####.png”);
The challenge is the resolution size. For web should be smaller than print aand the images should be the same > have to be generated within one instance.
Ok I just tested it and if you use the PDF export, using save()
doesn’t work :
import processing.pdf.*;
void setup() {
size(400, 400, PDF, "filename.pdf");
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
save("test.png");
// Exit the program
println("Finished.");
exit();
}
--> RuntimeException: No save() for PGraphicsPDF
You might want to run your code twice, one with the PDF export and another one with save(...)
void mousePressed() {
saveFrame("balls-#####.png");
surface.setResizable(true);
surface.setSize(7200, 9600);
pdf = (PGraphicsPDF)beginRecord(PDF, "test.pdf");
endRecord();
exit();
}
But the pdf can’t be opened :-/
I created a generative scipt. In case I run the code twice the result is slightly different.
Then the solution is to export a PDF and then open it in an image editor like Gimp and export it as png
okay sounds simpel I will give it a try
This code works, only the pdf is empty (but I can open it)
This is because there is no drawing operation between the beginRecord()
and endRecord()
functions.
This code works thought (without using PDF
in the size()
method) :
import processing.pdf.*;
void setup() {
size(400, 400);
noLoop();
beginRecord(PDF, "filename.pdf");
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
save("test.png");
endRecord();
}
Ah I know, because only the code between begin/end Record is stored
In fact your code works. But the program crashes if I set the canvas size to 2400x3200 for high res resolution :-/
Thanks anyway!
If your program is crashing due to file size you might want to try increasing the available memory.
File > Preferences