Package org.xhtmlrenderer.pdf.util
Class XHtmlMetaToPdfInfoAdapter
- java.lang.Object
-
- org.xhtmlrenderer.pdf.DefaultPDFCreationListener
-
- org.xhtmlrenderer.pdf.util.XHtmlMetaToPdfInfoAdapter
-
- All Implemented Interfaces:
PDFCreationListener
public class XHtmlMetaToPdfInfoAdapter extends DefaultPDFCreationListener
Description
This PDF Creation Listener parses meta data elements from an (X)HTML document and appends them to the info dictionary of a PDF document.
The XHTML document is parsed for relevant PDF meta data during construction, then adds the meta data to the PDF document when the PDF document is closed by the calling ITextRenderer.
Valid (X)HTML tags are:
- TITLE
Valid (X)HTML meta tag attribute names are:
- TITLE (optional), DC.TITLE
- CREATOR, AUTHOR, DC.CREATOR
- SUBJECT, DC.SUBJECT
- KEYWORDS
Valid PDF meta names are defined in Adobe's PDF Reference (Sixth Edition), section "10.2.1 - Document Information Dictionary", table 10.2, pg.844 ...
Usage
// Setup output stream OutputStream outputStream = ... // Create W3C document model Document doc = ... // Create new PDF renderer ITextRenderer renderer = new ITextRenderer(); // Add PDF creation listener PDFCreationListener pdfCreationListener = new XHtmlMetaToPdfInfoAdapter( doc ); renderer.setListener( pdfCreationListener); // Add W3C document to renderer renderer.setDocument( doc, null ); // Layout PDF document renderer.layout(); // Write PDF document renderer.createPDF( outputStream, true );
Notes
This class was derived from a sample PDF creation listener at "http://markmail.org/message/46t3bw7q6mbhvra2" by Jesse Keller. - Author:
- Tim Telcik
- See Also:
DefaultPDFCreationListener
,PDFCreationListener
,ITextRenderer
, ..., ..., ...
-
-
Constructor Summary
Constructors Constructor Description XHtmlMetaToPdfInfoAdapter(Document doc)
Creates a new adapter from the given XHTML document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onClose(ITextRenderer renderer)
PDFCreationListener onClose event handler.-
Methods inherited from class org.xhtmlrenderer.pdf.DefaultPDFCreationListener
preOpen, preWrite
-
-
-
-
Constructor Detail
-
XHtmlMetaToPdfInfoAdapter
public XHtmlMetaToPdfInfoAdapter(Document doc)
Creates a new adapter from the given XHTML document.- Parameters:
doc
- XHTML document
-
-
Method Detail
-
onClose
public void onClose(ITextRenderer renderer)
PDFCreationListener onClose event handler.- Specified by:
onClose
in interfacePDFCreationListener
- Overrides:
onClose
in classDefaultPDFCreationListener
- Parameters:
renderer
- the iTextRenderer preparing the document- See Also:
PDFCreationListener
-
-