Document Template - Different Header on Page 1 (HTML)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 04:43 PM
Trying to work out if there is a way with document template scripts to have a different header and footer on page one of a document?
The requirement is for full width header and footer images on page 1 (page number is OK), and then just page numbers on following pages. I'm wondering if this could be done by inserting a page break and using a script on page 1 for the header and footer images?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 07:03 PM
@gregcurtis Have you tried below :
First Page Header and Footer:
Full-width header and footer images are added using <img> tags with Base64-encoded images ( or any other suitable ways) :
1.
// Create the first page with a full-width header and footer
var firstPageHeader = '<div style="text-align: center; width: 100%;"><img src="data:image/png;base64,[BASE64_HEADER_IMAGE]" alt="Header" style="width: 100%;"></div>';
var firstPageFooter = '<div style="text-align: center; width: 100%;"><img src="data:image/png;base64,[BASE64_FOOTER_IMAGE]" alt="Footer" style="width: 100%;"></div>';
// Set the first page header and footer
template.setHeader(firstPageHeader);
template.setFooter(firstPageFooter);
// Add content for the first page
..........
2.
// Insert a page break
template.print('<div style="page-break-after: always;"></div>');
3.
// Create headers and footers for subsequent pages
var subsequentPageHeader = '<div style="text-align: right;">Page ${PAGE}</div>';
var subsequentPageFooter = '<div style="text-align: center;">Page ${PAGE}</div>';
// Set subsequent page header and footer template.setHeader(subsequentPageHeader); template.setFooter(subsequentPageFooter);
// Add content for subsequent pages
......
How this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 08:01 PM
Thanks @Abhay Kumar1, but they don't work as Document Template Scripts (sn_doc_template_script) - the scripts just appear as "null" in the document body.
I also tried inserting the script into the source code of the HTML Template but that didn't work either.