Skip to content

Instantly share code, notes, and snippets.

@devongovett
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devongovett/9928620 to your computer and use it in GitHub Desktop.
Save devongovett/9928620 to your computer and use it in GitHub Desktop.
Set the height of a PDF page retroactively
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;
@skaag
Copy link

skaag commented Apr 2, 2014

Tried this, it bugs out. Cuts the top off.
Here's my CoffeeScript:
https://gist.github.com/skaag/9928676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment