Last active
August 29, 2015 13:58
-
-
Save devongovett/9928620 to your computer and use it in GitHub Desktop.
Set the height of a PDF page retroactively
This file contains 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
doc.addPage(); | |
// add content | |
// this sets the height in the actual PDF output | |
// MediaBox[1] is really the Y, but PDFs use a flipped coordinate system | |
// where y=0 is at the bottom. | |
// make sure you do this before adding another page | |
doc.page.dictionary.data.MediaBox[1] = doc.page.height - doc.y; | |
// set the height (just used for layout, you might be able to get | |
// away without setting it if not adding anything more to the page) | |
doc.page.height = doc.y; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this, it bugs out. Cuts the top off.
Here's my CoffeeScript:
https://gist.github.com/skaag/9928676