DocRaptor HTML TO PDF API

Margins & Bleed

You’re probably familiar with web page document margins, typically set on the <body> or sometimes the <html> elements The concept is similar for DocRaptor PDFs, with some additional capabilities. You can set a margin for each page or customize the margin for different pages.

Defining margins is important for most PDFs because page region content (such as headers or page numbers) lives in the margin area of the page.

By default, DocRaptor pages have a margin of `0.75in`, but this can be easily changed:

@page {
  margin: 50px;
}

A margin of 0 will generate a full-bleed page.

Many printed documents need different margins on the inside of the page (where a book might be bound) versus the outside of the page. This can be accomplished through a Prince CSS expansion:

@page {
  margin-inside: 2in;
  margin-outside: 1in;
}

Margins for different pages can be set with named pages or pseudo-classes, such as:

@page:first {
  margin: 0;
}

Ready to get started? Try DocRaptor for free with unlimited test documents.