We are looking to add full-width headers and footers to a PDF generated with iText pdfhtml. We've got the headers and footers generating correctly, however we are unable to size the sections. Upon further digging we ran across the issue here, where the width is explicitly set to 33% for each margin box:
We are hoping someone from the itext team might be able to point us to another approach, possibly a custom Tag Worker? Otherwise, we could look into coordinating the 3 header/footer boxes, to accomplish something similar.
Here's some sample css, that kind of illustrates what we are trying to do
#page-header {
width: 8in; /* Or any width really - which is ignored */
position: running(header);
}
@page {
@top-center {
width: 8in; /* Adding width here, is also ignored */
content: element(header);
}
}
Support of custom widths in top page sections as in your example has been added in the current iText 7.1.5-SNAPSHOT
/ pdfHTML 2.1.2-SNAPSHOT
development versions. It will become available with the next public release.
Meanwhile, you can use the development version of the library for now. It can be accessed from iText Artifactory with the following Maven configuration:
<repositories>
<repository>
<id>itext-snapshot</id>
<name>iText Repository - snapshots</name>
<url>https://repo.itextsupport.com/snapshot</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.1.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>2.1.2-SNAPSHOT</version>
</dependency>
</dependencies>