Created
October 14, 2012 09:18
-
-
Save timpulver/3888092 to your computer and use it in GitHub Desktop.
[Processing] Specifying PDF page size in Processing (Processing 2.0 alpha)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import processing.pdf.*; | |
| import com.lowagie.text.PageSize; | |
| import com.lowagie.text.Rectangle; | |
| /** | |
| * Hack to use dinA paper formats | |
| * Originally posted by http://toxi.co.uk, I made small changes to use it with Processing 2.0 alpha. | |
| */ | |
| void setup() { | |
| // create window @ A3 landscape using OPENGL | |
| pageSize(com.lowagie.text.PageSize.A3,true,OPENGL); | |
| } | |
| /* | |
| void setup() { | |
| // create window @ US Letter size, portrait using default renderer | |
| pageSize(com.lowagie.text.PageSize.LETTER,false,JAVA2D); | |
| } | |
| */ | |
| /** | |
| * Convenience method to be used instead of the normal size() command. | |
| * Creates window matched to a given paper size | |
| * | |
| * @param r a predefined constant of the iText PageSize class | |
| * @param isLandscape true, if you want landscape orientation | |
| * @param renderer class name of the Processing renderer to use | |
| */ | |
| void pageSize(com.lowagie.text.Rectangle r, boolean isLandscape, String renderer) { | |
| //println(r.getWidth() + ", " + r.getHeight()); | |
| if (isLandscape) { | |
| size((int)r.getHeight(),(int)r.getWidth(),renderer); | |
| } else { | |
| size((int)r.getWidth(),(int)r.getHeight(),renderer); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment