Class HtmlHeaderFooter
- All Implemented Interfaces:
Cloneable
When using HtmlHeaderFooter it is important to set htmlFragment
Merge meta-data into your html using any of these placeholder strings: {page} {total-pages} {url} {date} {time} {html-title} {pdf-title}
See:ChromePdfRenderOptions.setHtmlHeader(HtmlHeaderFooter)
& ChromePdfRenderOptions.setHtmlFooter(HtmlHeaderFooter)
See:PdfDocument.addHtmlHeader(HtmlHeaderFooter)
& PdfDocument.addHtmlFooter(HtmlHeaderFooter)
-
Constructor Summary
ConstructorDescriptionInstantiates a new Html header footer.HtmlHeaderFooter
(String htmlFragment) Instantiates a new Html header footer. -
Method Summary
Modifier and TypeMethodDescriptionClone()
SupportsCloneable
.The Base URL all URLS in thehtmlFragment
" will be relative to.The Html which will be used to render the Header / Footer.Maximum Height of the Html Header / Footer in millimeters.boolean
A horizontal line divider between the header / footer and the page content on every page of the PDF document.boolean
Loads style code blocks and links to CSS style sheets from the main HTML document (which provides the PDF content) into theHtmlHeaderFooter
.void
setBaseUrl
(String value) The Base URL all URLS in thehtmlFragment
" will be relative to.void
setDrawDividerLine
(boolean value) Adds a horizontal line divider between the header / footer and the page content on every page of the PDF document.void
setHtmlFragment
(String value) The Html which will be used to render the Header / Footer.void
setLoadStylesAndCSSFromMainHtmlDocument
(boolean value) Loads style code blocks and links to CSS style sheets from the main HTML document (which provides the PDF content) into theHtmlHeaderFooter
.void
setMaxHeight
(Integer value) Maximum Height of the Html Header / Footer in millimeters.
-
Constructor Details
-
HtmlHeaderFooter
public HtmlHeaderFooter()Instantiates a new Html header footer. -
HtmlHeaderFooter
Instantiates a new Html header footer.- Parameters:
htmlFragment
- the html fragment
-
-
Method Details
-
getMaxHeight
Maximum Height of the Html Header / Footer in millimeters. This value must be set sufficiently high to display the full html header / footer content.- Returns:
- the max height
-
setMaxHeight
Maximum Height of the Html Header / Footer in millimeters. This value must be set sufficiently high to display the full html header / footer content.- Parameters:
value
- the value
-
isDrawDividerLine
public boolean isDrawDividerLine()A horizontal line divider between the header / footer and the page content on every page of the PDF document.- Returns:
- the boolean
-
setDrawDividerLine
public void setDrawDividerLine(boolean value) Adds a horizontal line divider between the header / footer and the page content on every page of the PDF document.- Parameters:
value
- the value
-
getBaseUrl
The Base URL all URLS in thehtmlFragment
" will be relative to. This includes 'src' attributes on images, scripts, style-sheets and also hrefs on hyperlinks.Note: A base URL that points to a directory should end with a slash.
Base URL accepts file paths as well as URLS. If no BaseUrl is given, the HtmlHeaderFooter BaseUrl will be inherited from the main HTML document where possible.
- Returns:
- the base url
-
setBaseUrl
The Base URL all URLS in thehtmlFragment
" will be relative to. This includes 'src' attributes on images, scripts, style-sheets and also hrefs on hyperlinks.Note: A base URL that points to a directory should end with a slash.
Base URL accepts file paths as well as URLS. If no BaseUrl is given, the HtmlHeaderFooter BaseUrl will be inherited from the main HTML document where possible.
- Parameters:
value
- the value
-
getHtmlFragment
The Html which will be used to render the Header / Footer. Should be a Html snippet rather than a complete document. May contain styles & images.Merge meta-data into the HtmlFragment by putting any of these placeholder strings into the text: {page} {total-pages} {url} {date} {time} {html-title} {pdf-title}. An alternative mail-merge style using the pattern <span class='total-pages'></span> also work
HtmlFragment is a stand alone HTML document which does not inherit styles or settings from your main HTML content unless
loadStylesAndCSSFromMainHtmlDocument
is set true- Returns:
- the html fragment
-
setHtmlFragment
The Html which will be used to render the Header / Footer. Should be a Html snippet rather than a complete document. May contain styles & images.Merge meta-data into the HtmlFragment by putting any of these placeholder strings into the text: {page} {total-pages} {url} {date} {time} {html-title} {pdf-title}. An alternative mail-merge style using the pattern <span class='total-pages'></span> also work
HtmlFragment is a stand alone HTML document which does not inherit styles or settings from your main HTML content unless
loadStylesAndCSSFromMainHtmlDocument
is set true- Parameters:
value
- the value
-
isLoadStylesAndCSSFromMainHtmlDocument
public boolean isLoadStylesAndCSSFromMainHtmlDocument()Loads style code blocks and links to CSS style sheets from the main HTML document (which provides the PDF content) into theHtmlHeaderFooter
.By default, Html Headers and Footers are stand- alone HTML documents with their own default styles. Setting
loadStylesAndCSSFromMainHtmlDocument
to true will attempt to load all STYLE and LINK tags from the main HTML document (which renders teh PDF) into theHtmlHeaderFooter
.If your main HTML document contains complex CSS frameworks, styles the HEAD or BODY element heavily or loads CSS from javascript then this method may not work as intended.
This feature is not available for RenderUrlAsPdf methods. It works for HTMLToPdf and HtmlFileToPdf conversions only.
It is often preferable to load style sheets explicitly into your HTML Headers and Footers as STYLE and LINK tags within the
htmlFragment
for granular control- Returns:
- the boolean
-
setLoadStylesAndCSSFromMainHtmlDocument
public void setLoadStylesAndCSSFromMainHtmlDocument(boolean value) Loads style code blocks and links to CSS style sheets from the main HTML document (which provides the PDF content) into theHtmlHeaderFooter
.By default, Html Headers and Footers are stand- alone HTML documents with their own default styles. Setting
loadStylesAndCSSFromMainHtmlDocument
to true will attempt to load all STYLE and LINK tags from the main HTML document (which renders teh PDF) into theHtmlHeaderFooter
.If your main HTML document contains complex CSS frameworks, styles the HEAD or BODY element heavily or loads CSS from javascript then this method may not work as intended.
This feature is not available for RenderUrlAsPdf methods. It works for HTMLToPdf and HtmlFileToPdf conversions only.
It is often preferable to load style sheets explicitly into your HTML Headers and Footers as STYLE and LINK tags within the
htmlFragment
for granular control- Parameters:
value
- the value
-
Clone
SupportsCloneable
. Creates a deep copy of this class instance.- Returns:
- A deep clone of this instance. Use explicit casting to convert object back to the intended type.
- Throws:
CloneNotSupportedException
- the clone not supported exception
-