Мы используем Chromium Playwright для преобразования HTML в PDF, где на PDF устанавливается водяной знак для заголовка. Но заголовок необходимо добавить на всех страницах, кроме как на странице 1. Ниже приведен метод установки Headertemplate < /p> // Header
pdfOptions.setHeaderTemplate(
header.map(h ->
"" +
"" + h + "" +
"" +
"if (parseInt(document.querySelector('.pageNumber').textContent) === 1) {" +
" document.currentScript.parentElement.style.display='none';" +
"}" +
"" +
""
).orElse("")
);
// Footer
pdfOptions.setFooterTemplate(
footer.map(f ->
" "position: relative; " +
"display: flex; justify-content: flex-end; " +
"padding-right: 30px; " +
"padding-top: 10px; " +
"box-sizing: border-box;'>" +
f + " | Page of " +
""
).orElse(
" "position: relative; " +
"display: flex; justify-content: flex-end; " +
"padding-right: 30px; " +
"padding-top: 10px; " +
"box-sizing: border-box;'>" +
"Page of " +
""
)
);
Подробнее здесь: https://stackoverflow.com/questions/797 ... sing-chrom
Мобильная версия