Generating an A5 PDF document from HTML using Java iText <p>I'd like to generate an A5 page-size PDF document from a given HTML template using the iText Java library.</p> <p>I have been successful in generating a PDF, but rather than one A5 page, I get one A4 page (with the text on it) followed by an empty A5 page (see: <a href="http://sdrv.ms/11tAmlq" rel="nofollow">the output document</a>). What am I doing wrong?</p> <p>A sample java code follows.</p> <p>Many thanks for help.</p> <pre><code> public final class Main { public static void main(String[] args) throws IOException, DocumentException { htmlToPdf(new StringReader("&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello, World!!!&lt;/title&gt;&lt;/head&gt;&lt;body style=\"font-family: 'Times New Roman', serif;\"&gt;&lt;div&gt;Hello, World!!!&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;"), new File("Test.pdf")); } private static void htmlToPdf(final StringReader htmlSource, final File pdfOutput) throws IOException, DocumentException { final FileOutputStream pdfOutputStream = new FileOutputStream(pdfOutput); final PdfDocument document = new PdfDocument(); FontFactory.defaultEmbedding = true; document.setPageSize(com.itextpdf.text.PageSize.A5); final PdfWriter pdfWriter = PdfAWriter.getInstance(document, pdfOutputStream, PdfAConformanceLevel.PDF_A_1B); document.addWriter(pdfWriter); document.open(); XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document, htmlSource); document.close(); pdfOutputStream.close(); } } </code></pre>