com.qoppa.pdf
Class DocumentInfo

java.lang.Object
  extended by com.qoppa.pdf.DocumentInfo

public abstract class DocumentInfo
extends Object

This class is a container for the information section of a PDF document. This section contains fields such as author, title, subject, keywords, etc.

Author:
Qoppa Software

Field Summary
static String KEY_AUTHOR
           
static String KEY_CREATIONDATE
           
static String KEY_CREATOR
           
static String KEY_KEYWORDS
           
static String KEY_MODDATE
           
static String KEY_PRODUCER
           
static String KEY_SUBJECT
           
static String KEY_TITLE
           
 
Constructor Summary
DocumentInfo()
           
 
Method Summary
abstract  String getAuthor()
          Returns the document's author.
abstract  Date getCreationDate()
          Returns the document's creation date.
abstract  String getCreator()
          Returns the document's creator.
abstract  String getCustomProperty(String key)
          Returns the value of a custom property.
static DocumentInfo getDocumentInfo(InputStream inStream, IPassword password)
          Static method to get the document information from a document from an InputStream.
static DocumentInfo getDocumentInfo(String fileName, IPassword passwords)
          Static method to get the document information from a document in a file.
static DocumentInfo getDocumentInfo(URL url, IPassword password)
          Static method to get the document information from a document from a URL.
abstract  String getKeywords()
          Returns the document's keywords.
abstract  Date getModDate()
          Returns the document's modified date.
abstract  int getPageCount()
          Gets the number of pages in the document.
abstract  String getProducer()
          Returns the document's producer.
abstract  String getSubject()
          Returns the document's subject.
abstract  String getTitle()
          Gets the document's title.
abstract  byte[] getXMPMetadata()
          Returns the raw XMP metadata in the document as an array of bytes.
abstract  String getXMPMetadata(String charsetName)
          Returns the XMP metadata in the document.
abstract  void setAuthor(String author)
          Set the document's author.
abstract  void setCreationDate(Date creationDate)
          Set the document's creation date.
abstract  void setCreator(String creator)
          Set the document's creator.
abstract  void setCustomProperty(String key, String value)
          Sets a custom application property in the document info for the document.
abstract  void setKeywords(String keywords)
          Set the document's keywords.
abstract  void setModifiedDate(Date modDate)
          Set the document's modified date.
abstract  void setProducer(String producer)
          Set the document's producer.
abstract  void setSubject(String subject)
          Set the document's subject.
abstract  void setTitle(String title)
          Sets the document's title.
abstract  void setXMPMetadata(byte[] xmpData)
          Sets the XMP metadata block in the document.
abstract  void setXMPMetadata(String xmpString, String charsetName)
          Sets the XMP metadata block in the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_TITLE

public static final String KEY_TITLE
See Also:
Constant Field Values

KEY_AUTHOR

public static final String KEY_AUTHOR
See Also:
Constant Field Values

KEY_SUBJECT

public static final String KEY_SUBJECT
See Also:
Constant Field Values

KEY_KEYWORDS

public static final String KEY_KEYWORDS
See Also:
Constant Field Values

KEY_CREATOR

public static final String KEY_CREATOR
See Also:
Constant Field Values

KEY_PRODUCER

public static final String KEY_PRODUCER
See Also:
Constant Field Values

KEY_CREATIONDATE

public static final String KEY_CREATIONDATE
See Also:
Constant Field Values

KEY_MODDATE

public static final String KEY_MODDATE
See Also:
Constant Field Values
Constructor Detail

DocumentInfo

public DocumentInfo()
Method Detail

getDocumentInfo

public static DocumentInfo getDocumentInfo(String fileName,
                                           IPassword passwords)
                                    throws PDFException
Static method to get the document information from a document in a file.

Parameters:
fileName - The name of the file.
passwords - An object that provides passwords to open the document, leave null if not needed. When working with documents that have no passwords, the host application should pass null for the value of this parameter. When documents are known to have passwords, the host application should pass an instance of the PDFPassword class that can hold a single password or a list of passwords.
Returns:
A DocumentInfo object containing the PDF document's header information.
Throws:
PDFException

getDocumentInfo

public static DocumentInfo getDocumentInfo(InputStream inStream,
                                           IPassword password)
                                    throws PDFException
Static method to get the document information from a document from an InputStream.

Parameters:
inStream - InputStream that will be used to read the PDF document.
password - An object that provides passwords to open the document, leave null if not needed. When working with documents that have no passwords, the host application should pass null for the value of this parameter. When documents are known to have passwords, the host application should pass an instance of the PDFPassword class that can hold a single password or a list of passwords.
Returns:
A DocumentInfo object containing the PDF document's header information.
Throws:
PDFException

getDocumentInfo

public static DocumentInfo getDocumentInfo(URL url,
                                           IPassword password)
                                    throws PDFException
Static method to get the document information from a document from a URL.

Parameters:
url - The url where the PDF document can be found.
password - An object that provides passwords to open the document, leave null if not needed. When working with documents that have no passwords, the host application should pass null for the value of this parameter. When documents are known to have passwords, the host application should pass an instance of the PDFPassword class that can hold a single password or a list of passwords.
Returns:
A DocumentInfo object containing the PDF document's header information.
Throws:
PDFException

getTitle

public abstract String getTitle()
Gets the document's title.

Returns:
The document title.

setTitle

public abstract void setTitle(String title)
                       throws PDFException
Sets the document's title.

Parameters:
title - The document's title.
Throws:
PDFException

getAuthor

public abstract String getAuthor()
Returns the document's author.

Returns:
The document's author.

getSubject

public abstract String getSubject()
Returns the document's subject.

Returns:
The document's subject.

getKeywords

public abstract String getKeywords()
Returns the document's keywords.

Returns:
The document's keywords.

getCreator

public abstract String getCreator()
Returns the document's creator.

Returns:
The document's creator.

getProducer

public abstract String getProducer()
Returns the document's producer.

Returns:
The document's producer.

getCreationDate

public abstract Date getCreationDate()
Returns the document's creation date.

Returns:
The document's creation date.

getModDate

public abstract Date getModDate()
Returns the document's modified date.

Returns:
The document's modified date.

getPageCount

public abstract int getPageCount()
Gets the number of pages in the document.

Returns:
Number of pages.

setAuthor

public abstract void setAuthor(String author)
                        throws PDFException
Set the document's author.

Parameters:
author - The document's author.
Throws:
PDFException

setCreationDate

public abstract void setCreationDate(Date creationDate)
                              throws PDFException
Set the document's creation date.

Parameters:
creationDate - The document's creation date.
Throws:
PDFException

setCreator

public abstract void setCreator(String creator)
                         throws PDFException
Set the document's creator.

Parameters:
creator - The document's creator.
Throws:
PDFException

setKeywords

public abstract void setKeywords(String keywords)
                          throws PDFException
Set the document's keywords.

Parameters:
keywords - The document's keywords.
Throws:
PDFException

setModifiedDate

public abstract void setModifiedDate(Date modDate)
                              throws PDFException
Set the document's modified date.

Parameters:
modDate - The document's modified date.
Throws:
PDFException

setProducer

public abstract void setProducer(String producer)
                          throws PDFException
Set the document's producer.

Parameters:
producer - The document's producer.
Throws:
PDFException

setSubject

public abstract void setSubject(String subject)
                         throws PDFException
Set the document's subject.

Parameters:
subject - The document's subject.
Throws:
PDFException

getXMPMetadata

public abstract String getXMPMetadata(String charsetName)
                               throws UnsupportedEncodingException
Returns the XMP metadata in the document.

Parameters:
charsetName - The name of the character set to use when decoding the XMP data stream. Every implementation of Java is supposed to support US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE and UTF-16
Returns:
the XMP metadata, as a String holding XML data.
Throws:
UnsupportedEncodingException

setXMPMetadata

public abstract void setXMPMetadata(String xmpString,
                                    String charsetName)
                             throws PDFException,
                                    UnsupportedEncodingException
Sets the XMP metadata block in the document. The xmpString should be properly formatted XMP XML data.

Parameters:
xmpString - The new XMP block.
charsetName - The name of the character set to use when encoding the XMP string to bytes. Every implementation of Java is supposed to support US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE and UTF-16
Throws:
PDFException
UnsupportedEncodingException

setXMPMetadata

public abstract void setXMPMetadata(byte[] xmpData)
                             throws PDFException
Sets the XMP metadata block in the document. The xmpData should already be encoded in the desired encoding, this method simply puts the bytes directly into the PDF document.

Throws:
PDFException

getXMPMetadata

public abstract byte[] getXMPMetadata()
Returns the raw XMP metadata in the document as an array of bytes.

Returns:
the XMP metadata, as an array of bytes holding XML data.

setCustomProperty

public abstract void setCustomProperty(String key,
                                       String value)
                                throws PDFException
Sets a custom application property in the document info for the document. The PDF format allows for applications setting their own properties, but it is up to the application to make sure that these properties do not conflict with standard properties.

Parameters:
key - The property key or name
value - The value of the property.
Throws:
PDFException

getCustomProperty

public abstract String getCustomProperty(String key)
Returns the value of a custom property. The PDF format allows for applications setting their own properties, but it is up to the application to make sure that these properties do not conflict with standard properties.

Parameters:
key - The name of the property
Returns:
the value of the custom property