public class Metadata extends NativeObject
Represents the metadata of a document or an object in a document.
For document level metadata, all changes are reflected in both, XMP metadata and document info dictionary depending on the conformance of the document.
Modifier and Type | Method and Description |
---|---|
static Metadata |
copy(Document targetDocument,
Metadata metadata)
Copy a metadata object
|
static Metadata |
create(Document targetDocument,
Stream xmp)
Create a new metadata object
|
static Metadata |
createDynamicObject(long handle) |
java.lang.String |
getAuthor()
The name of the person who created the document or resource.
|
java.time.OffsetDateTime |
getCreationDate()
The date and time the document or resource was originally created.
|
java.lang.String |
getCreator()
The original application that created the document.
|
StringMap |
getCustomEntries()
The custom entries in the document information dictionary (Getter)
|
java.lang.String |
getKeywords()
Keywords associated with the document or resource.
|
java.time.OffsetDateTime |
getModificationDate()
The date and time the document or resource was most recently modified.
|
java.lang.String |
getProducer()
The application that created the PDF (Getter)
|
java.lang.String |
getSubject()
The subject of the document or resource.
|
java.lang.String |
getTitle()
The title of the document or resource.
|
Stream |
getXmp()
The XMP metadata (Getter)
|
void |
setAuthor(java.lang.String value)
The name of the person who created the document or resource.
|
void |
setCreationDate(java.time.OffsetDateTime value)
The date and time the document or resource was originally created.
|
void |
setCreator(java.lang.String value)
The original application that created the document.
|
void |
setKeywords(java.lang.String value)
Keywords associated with the document or resource.
|
void |
setSubject(java.lang.String value)
The subject of the document or resource.
|
void |
setTitle(java.lang.String value)
The title of the document or resource.
|
equals, hashCode
public static Metadata createDynamicObject(long handle)
public static Metadata create(Document targetDocument, Stream xmp) throws java.io.IOException, CorruptException
Document.setMetadata(com.pdf_tools.fourheights.pdftoolbox.pdf.Metadata)
or as page metadata using Page.setMetadata(com.pdf_tools.fourheights.pdftoolbox.pdf.Metadata)
.targetDocument
- the output document with which the returned object is associatedxmp
- A stream containing an XMP file or null
to
create an empty metadata object.java.lang.IllegalArgumentException
- if the targetDocument
argument is null
java.lang.IllegalArgumentException
- if the targetDocument
argument has already been closedjava.lang.IllegalArgumentException
- if the targetDocument
argument is read-onlyjava.io.IOException
- if the xmp
stream could not be readCorruptException
- if the xmp
stream is corruptpublic static Metadata copy(Document targetDocument, Metadata metadata) throws java.io.IOException, CorruptException, ConformanceException
targetDocument
.
The returned object is associated with the target document but not
(yet) used as the document metadata.
The object can be used either as document metadata using Document.setMetadata(com.pdf_tools.fourheights.pdftoolbox.pdf.Metadata)
or as page metadata using Page.setMetadata(com.pdf_tools.fourheights.pdftoolbox.pdf.Metadata)
.targetDocument
- the output document with which the returned object is associatedmetadata
- the metadata of a different documentjava.io.IOException
- Error reading from the source document or writing to the target documentCorruptException
- The source document is corruptConformanceException
- The conformance level of the source document is not compatible
with the conformance level of the target document.java.lang.IllegalArgumentException
- if the targetDocument
argument is null
java.lang.IllegalArgumentException
- if the targetDocument
argument has already been closedjava.lang.IllegalArgumentException
- if the targetDocument
argument is read-onlyjava.lang.IllegalArgumentException
- if the metadata
argument is null
java.lang.IllegalArgumentException
- if the metadata
object has already been closedjava.lang.IllegalArgumentException
- if the metadata
object is not associated with an input documentpublic java.lang.String getTitle()
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setTitle(java.lang.String value)
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.lang.String getAuthor()
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setAuthor(java.lang.String value)
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.lang.String getSubject()
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setSubject(java.lang.String value)
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.lang.String getKeywords()
Keywords can be separated by:
Setting this property also sets the XMP property dc:subject accordingly.
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setKeywords(java.lang.String value)
Keywords can be separated by:
Setting this property also sets the XMP property dc:subject accordingly.
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.lang.String getCreator()
The name of the first known tool used to create the document or resource.
This property corresponds to the "xmp:CreatorTool" entry in the XMP metadata and to the "Creator" entry in the document information dictionary.
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setCreator(java.lang.String value)
The name of the first known tool used to create the document or resource.
This property corresponds to the "xmp:CreatorTool" entry in the XMP metadata and to the "Creator" entry in the document information dictionary.
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.lang.String getProducer()
If the document was converted to PDF from another format, the name of the PDF processor that converted it to PDF.
This property corresponds to the "pdf:Producer" entry in the XMP metadata and to the "Producer" entry in the document information dictionary.
java.lang.IllegalStateException
- if the metadata have already been closedpublic java.time.OffsetDateTime getCreationDate()
java.lang.IllegalStateException
- if the metadata have already been closedpublic void setCreationDate(java.time.OffsetDateTime value)
java.lang.IllegalStateException
- if the metadata have already been closedjava.lang.UnsupportedOperationException
- the document is read-onlypublic java.time.OffsetDateTime getModificationDate() throws CorruptException
CorruptException
- The date is corrupt.java.lang.IllegalStateException
- if the metadata have already been closedpublic Stream getXmp()
The XMP metadata stream or null
if there is none.
The stream is read-only. To set the XMP stream of a metadata object use the method Document.CreateMetadata instead.
java.lang.IllegalStateException
- if the metadata have already been closedpublic StringMap getCustomEntries()
The standard entries "Title", "Author", "Subject", "Keywords", "CreationDate", "ModDate", "Creator", "Producer" and "Trapped" are not included in the map. Any attempt to set a standard entry through this map will result in an error. To get or set standard entries use the corresponding properties instead.
Note: The document information dictionary has been superseded by XMP metadata and is deprecated in PDF 2.0.
java.lang.IllegalStateException
- if the metadata have already been closed