I've tried to use the below HTML template to convert it to PDF using iText7 but both header and footer are not binding to their intended position. used example I'm trying to avoid @Page header and footer properties since I'm trying to accomplish fitting dynamic content in both sections with extended space more than 3 rows in each.
iText code and result:
ConverterProperties properties = new ConverterProperties();
//properties.setFontProvider(fontProvider);
properties.setMediaDeviceDescription(new MediaDeviceDescription(MediaType.PRINT));
PdfWriter writer = new PdfWriter("out.pdf");
PdfDocument pdf = new PdfDocument(writer);
pdf.setTagged();
PageSize pageSize = PageSize.LETTER;
pdf.setDefaultPageSize(pageSize);
OutlineHandler outlineHandler = OutlineHandler.createStandardHandler();
properties.setOutlineHandler(outlineHandler);
//html template (templateOutput)
HtmlConverter.convertToPdf(templateOutput, pdf, properties);
byte[] pdfData = byteArrayOutputStream.toByteArray();
pdf.close();
Please any suggestions to resolve the issue? Thank you
@page
media selector andrunning
elements in CSS to exclude an element from the main flow and include it into a header - Alexey Subachmargin-top
CSS declaration:@page { margin-top: 200px; }
- Alexey Subach