AFAICT, the PDF you're saving will encompass the area specified with the size() command. When specifying this size, don't worry about the size or resolution of your print-out or on-screen rendering just yet; they're not that important, as I'll explain in a moment.
You just have to make sure that you're laying everything out on your canvas as you want it to appear in the final document. This will only work if you specify a size with the correct aspect ratio (i.e. if you want to make a 10"x10" print-out of your document, it should be exactly as tall as it is wide), but you can pick any size you feel comfortable working with on your screen.
The vector shapes you're making with NodeBox have to be rasterized (turned into a grid of pixels with specific colours) to be displayed on your screen, but it's the pure vector shapes, not any rasterization, that end up in your PDF. The PDF will only be turned into concrete pixels once it hits a screen or printer; it doesn't have an intrinsic resolution itself. Therefore, I'd suggest: just get the aspect ratio and the composition of your canvas right, and defer worrying about resolution or size later.
The above is an over-simplification and not quite true in case you've actually got some pixel graphics in your document. Which might happen, for example, when you use the coreimage module. But as long as you're only making vector shapes, say with line(), lineto(), curveto(), text() etc., size doesn't matter at all and the above advice is perfectly good for you. Spare yourself the hassle and don't bother with any of the stuff I'm about to mention.
If you _do_ have to deal with pixel data, simply multiply resolution in dpi with size in inches to get the number of pixels you want; i.e. for a 10" x 10" PDF document that has a 300dpi resolution, do size(3000, 3000). But note that your screen most probably has a far lower resolution and the output will look unreasonably huge. You could deal with this by scale()ing everything down while you're working on it, and only getting rid of that scale() command once you're producing the final output.
Or you can just do this:
size(10*inch, 10*inch)(replacing the 10s with the actual size)
Thanks for the addendum, anonymous! According to the documentation,
size
doesn't take its arguments in pixels, as I erroneously stated above, but in points. A point is a typographical unit of measurement (as in "set the size of this text to 12pts") and there are 72 points to an inch, henceinch
always evaluates to 72, whether you're rendering to the screen or exporting to PDF.
When rendering to the screen (or a QuickTime movie), what
size
does in practice is setting the pixel dimensions and not the size in inches or cm. But when you're exporting to PDF and want the hardcopy to be the right size when printed at 100%, the above command will do exactly that trick.
Saving to PDF?
Posted by newbie73 on Sep 15, 2007Is it possible to save the image to a PDF document of a certain size? eg - how do I create a 10" x 10" PDF document that has a 300dpi resolution?