Top Description Constructors Methods
org.apache.pdfbox.pdmodel.common

public Class PDMetadata

extends PDStream
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, org.apache.pdfbox.cos.COSName, .COSStream, org.apache.pdfbox.pdmodel.PDDocument

This class represents metadata for various objects in a PDF document.
Author
Ben Litchfield

Constructor Summary

AccessConstructor and Description
public
PDMetadata(PDDocument
The document that the stream will be part of.
document
)

This will create a new PDMetadata object with the /Type and /Subtype entries for a document level metadata object.

public
PDMetadata(PDDocument
The document that will hold the stream.
doc
,
InputStream
The stream parameter.
str
)

Constructor.

public
PDMetadata(COSStream
The stream parameter.
str
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public InputStream

Returns:

A stream to get the xmp data from.
exportXMPMetadata
()

Extract the XMP metadata.

public void
importXMPMetadata(byte[]
The XMP data.
xmp
)

Import an XMP stream into the PDF document.

Inherited from org.apache.pdfbox.pdmodel.common.PDStream:
createInputStreamcreateInputStreamcreateInputStreamcreateOutputStreamcreateOutputStreamgetCOSObjectgetDecodedStreamLengthgetDecodeParmsgetFilegetFileDecodeParamsgetFileFiltersgetFiltersgetLengthgetMetadatasetDecodedStreamLengthsetDecodeParmssetFilesetFileDecodeParamssetFileFilterssetFilterssetMetadatatoByteArray

Constructor Detail

PDMetadataback to summary
public PDMetadata(PDDocument document)

This will create a new PDMetadata object with the /Type and /Subtype entries for a document level metadata object.

Parameters
document:PDDocument

The document that the stream will be part of.

PDMetadataback to summary
public PDMetadata(PDDocument doc, InputStream str) throws IOException

Constructor. Reads all data from the input stream and embeds it into the document, this will close the InputStream. The /Type and /Subtype entries for a document level metadata object will be created.

Parameters
doc:PDDocument

The document that will hold the stream.

str:InputStream

The stream parameter.

Exceptions
IOException:
If there is an error creating the stream in the document.
PDMetadataback to summary
public PDMetadata(COSStream str)

Constructor. This will not set up the /Type and /Subtype entries.

Parameters
str:COSStream

The stream parameter.

Method Detail

exportXMPMetadataback to summary
public InputStream exportXMPMetadata() throws IOException

Extract the XMP metadata. To persist changes back to the PDF you must call importXMPMetadata.

Returns:InputStream

A stream to get the xmp data from.

Exceptions
IOException:
If there is an error parsing the XMP data.
importXMPMetadataback to summary
public void importXMPMetadata(byte[] xmp) throws IOException

Import an XMP stream into the PDF document.

Parameters
xmp:byte[]

The XMP data.

Exceptions
IOException:
If there is an error generating the XML document.