Print Preview
Two ways to preview the same document: an HTML paper view sized in real millimetres (what window.print()
sends to your printer) and the PDF view generated on the server. Change any setting and both update.
Northwind Print Co., Ltd.
Northwind Print Co., Ltd.
88 Rama VI Road, Ratchathewi, Bangkok 10400
Tax ID 0105559999999
INVOICE
INV-202610-005
DRAFT
DRAFT
BILL TO
Green Valley International School300 Moo 5, Nong Prue, Bang Lamung, Chon Buri 20150
Issue date21 Oct 2026
Due date20 Nov 2026
Amount due8,448.72
| # | Description | Qty | Unit price | Amount |
|---|---|---|---|---|
| 1 | Thermal Labels 50 x 30 mm (1,000) | 12 | 250.00 | 3,000.00 |
| 2 | Price Tag Labels (10 rolls) | 11 | 160.00 | 1,760.00 |
| 3 | Kraft Mailer Box S | 6 | 12.00 | 72.00 |
| 4 | Price Tag Labels (10 rolls) | 10 | 160.00 | 1,600.00 |
| 5 | Binder Clips Assorted (box) | 11 | 120.00 | 1,320.00 |
| 6 | Kraft Mailer Box S | 12 | 12.00 | 144.00 |
| Subtotal | 7,896.00 |
| VAT 7% | 552.72 |
| Total (THB) | 8,448.72 |
How it works
- HTML paper view - the page is a
<div>sized in realmm. CSS@page { size: 210mm 297mm; margin: 0 }sets the paper for the print dialog, and@media printinapp.csshides the sidebar and buttons. - PDF view - the iframe loads
/doc/view?key=invoice:5&preset=1...(HomeController.view). The response headerContent-Disposition: inlinemakes the browser show it;attachmentdownloads it. - Print PDF calls
iframe.contentWindow.print()- the browser's PDF viewer prints the server-made PDF.
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.inline().filename(doc.fileName()).build().toString())
.contentType(MediaType.APPLICATION_PDF)
.body(doc.bytes());
Files: web/PrintSetupController.java, templates/preview.html, web/Downloads.java.