Forum How do I...?

How can I make sure my document is only 1 page?

oodavid
We've been using PrinceXML for a while now to render our Certificates as PDFs, occasionally the certificate "spills over" to create a second page. It's not consistent.

We use a second library to trim off the first page and have realised this may be the cause of a small memory leak.

Any tips about how to do this with PrinceXML in CSS or HTML?

I was hoping the following would do it, but it doesn't:

// Be compact
@page {
  margin: 0;
  border: 0;
  padding: 0;
}
// Force single page
* {
  page-break-inside: avoid;
  page-break-before: avoid;
  page-break-after: avoid;
}
  1. stream.pdf1.1 MB
    Two Pages

Edited by oodavid

mikeday
You could absolutely position the root element of the document, then it will not be split across pages, or you could give it a fixed height and specify "overflow: hidden".
oodavid
@mikeday - thank you, I had to adjust my HTML a little, but it was as simple as:

body {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}