0
votes

I want to add a header and a footer, which becomes repeated, to my PDF which becomes created by iText7 by converting the HTML.

However, all examples I found so far on the internet describes how to create a blank PDF by code with header and footer.

Does anybody know how I can achive this? I already tried to use the CSS print media queries to specify some areas but it seems those are ignored by iText7.

The conversion is really simple:

string input = "Bestellung.html";
string output = "Bestellung.pdf";
HtmlConverter.ConvertToPdf(new FileInfo(input), new FileInfo(output));

bestellung.html is just a plain HTML file with some demo content.

1

1 Answers

0
votes

See mediaDeviceDescription under ConverterProperties.

If your input file uses this feature, then you can simply tell pdfHTML to interpret the relevant set of rules:

ConverterProperties props = new ConverterProperties();
props.setMediaDeviceDescription(new
MediaDeviceDescription(MediaType.PRINT));

Then you call the method with this signature:

static void convertToPdf(InputStream htmlStream, PdfDocument pdfDocument, ConverterProperties converterProperties)