367-370 Page Setup Studio

Page Setup Studio

Features 367 page numbers, 368 header/footer, 369 orientation and 370 paper size - plus the 366 watermark - on a real multi-page report. Every change re-renders the PDF on the right. Save the result as a preset and use it for invoices, templates and batch printing.

370 Paper size
A4
A5
A6
B5
US Letter
US Legal
Executive
369 Orientation & margins
367 Page numbers
366 Watermark
Sample report
Save as preset

Live PDF

Download

Saved presets

table print_preset
NamePaperOrientationMarginHeader / footerPage numbersWatermark
A4 Landscape report A4 LANDSCAPE 12 mm {company} - {title}
Confidential - internal use
{page} / {total} -
A5 Compact A5 PORTRAIT 10 mm {company}
-
{page}/{total} -
Clean (no header / footer) A4 PORTRAIT 12 mm -
-
- -
Draft copy (watermark) A4 PORTRAIT 15 mm {company}
DRAFT - not valid as a tax document
Page {page} of {total} DRAFT
Standard A4 default A4 PORTRAIT 15 mm {company}
{title} | Printed {date}
Page {page} of {total} -
US Letter LETTER PORTRAIT 19 mm {company}
Printed {date}
Page {page} -
How it works
  • 370 / 369 - PaperSize.toRectangle(orientation) converts millimetres to PDF points (1 mm = 72 / 25.4 pt) and swaps width and height for landscape.
  • 368 / 367 / 366 - PageDecorator extends OpenPDF's PdfPageEventHelper. onEndPage() runs once per page and draws the header, footer, page number and watermark.
  • "of {total}" - the total is unknown on page 1, so it is drawn into a PdfTemplate placeholder and filled in onCloseDocument().
  • Long tables call table.setHeaderRows(1), so the column titles repeat at the top of each page.
public void onEndPage(PdfWriter writer, Document document) {
    String text = format.replace("{page}", String.valueOf(writer.getPageNumber()));
    ...
    cb.addTemplate(totalBox, x, y);          // "{total}" placeholder
}
public void onCloseDocument(PdfWriter writer, Document document) {
    totalBox.showText(String.valueOf(writer.getPageNumber() - 1));
}
SELECT name, paper_size, orientation, margin_mm, page_number_format, watermark_text, is_default
FROM print_preset ORDER BY name;

Files: print/PageSetup.java, print/PaperSize.java, print/PageDecorator.java, print/PdfKit.java, service/PresetService.java.