public class FlyingSaucerMetadataCreationListener
extends org.xhtmlrenderer.pdf.DefaultPDFCreationListener
Implements PDFCreationListener
to extract metadata values from the
input XHTML, and inserts those values into the resulting PDF. Specifically,
XHTML meta
tags with the following name
attributes will have
their content
attributes inserted as the corresponding PDF metadata
keys:
For example, the following XHTML fragment would set the title
,
author
and subject
metadata keys in the PDF output:
<meta name="title" content="Foo Sales" />
<meta name="author" content="John Doe" />
<meta name="subject" content="Monthly sales of Foo" />
Further, in the absence of a "title" meta
element, the content of the
title
element will be used instead. That is, the following fragment
would produce the same output:
<title>Foo Sales</title>
<meta name="author" content="John Doe" />
<meta name="subject" content="Monthly sales of Foo" />
This class is based on code posted to the Flying Saucer project wiki, and is assumed to be in the public domain.
Constructor and Description |
---|
FlyingSaucerMetadataCreationListener() |
Modifier and Type | Method and Description |
---|---|
void |
parseMetaTags(Document sourceXHTML)
Parses the XHTML
meta tags into a property list. |
void |
preOpen(org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer) |
public FlyingSaucerMetadataCreationListener()
public void parseMetaTags(Document sourceXHTML)
meta
tags into a property list.sourceXHTML
- XHTML sourcepublic void preOpen(org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer)
preOpen
in interface org.xhtmlrenderer.pdf.PDFCreationListener
preOpen
in class org.xhtmlrenderer.pdf.DefaultPDFCreationListener
Copyright © 2002 – 2020 Project Wonder.