com.adobe.pdf
Interface PDFDocument


public interface PDFDocument

PDFDocument defines a public interface for manipulating PDF documents. Using a PDFDocument interface, you can programmatically perform the following tasks:

Note: For information about performing these tasks, see the Developer Guide.


Method Summary
 void deleteAnnotations()
          Deletes all annotations in a PDF document.
 void deleteFileAttachment(byte[] name)
          Deletes a file attachment in a PDF document that is associated with the given name.
 java.io.InputStream exportAnnotations()
          Exports a PDF document’s annotations as a stream of XFDF XML data.
 FileAttachment exportFileAttachment(byte[] name)
          Exports data associated with the given name as a FileAttachment object.
 java.io.InputStream exportFormData(FormDataFormat format)
          Exports a form’s data as an XFA or an XFDF data stream as specified by the format parameter.
 java.io.InputStream exportXMP()
          Exports the XMP metadata that is associated with a PDF document.
 byte[][] getFileAttachmentNames()
          Returns an array of names as byte arrays that references file attachments.
 FormType getFormType()
          Returns the form type on which a PDF document is based.
 java.util.List getImages()
          Returns a list of all images that are referenced by a PDF document.
 int getNumberOfPages()
          Returns the number of pages within the PDF document.
 java.lang.String getVersion()
          Returns the version of the PDF document.
 java.util.ListIterator getWords()
          Returns a list iterator for accessing the words in the content of the PDF document.
 void importAnnotations(java.io.InputStream xfdfAnnotations)
          Imports into a PDF document annotations that are represented in an XFDF XML data stream.
 void importFileAttachment(byte[] name, FileAttachment fileAttachment)
          Imports the specified FileAttachment object into a PDF document under the given name.
 void importFormData(java.io.InputStream src)
          Imports the form data as an XFA or an XFDF data stream.
 void importXMP(java.io.InputStream src)
          Ensures that the input stream that represents XML is valid and uses it to replace the metadata referenced by the PDF document.
 java.io.InputStream save()
          Returns the modified PDF document data stream.
 java.io.InputStream saveAsXDP()
          Returns the modified PDF document as an XDP data stream.
 

Method Detail

getVersion

public java.lang.String getVersion()
                            throws PDFException
Returns the version of the PDF document.

Returns:
A java.lang.string value that represents the version of the PDF document.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.

getNumberOfPages

public int getNumberOfPages()
                     throws PDFException
Returns the number of pages within the PDF document.

Returns:
An integer value that represents the number of pages.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.

getFormType

public FormType getFormType()
                     throws PDFException
Returns the form type on which a PDF document is based.

Returns:
A FormType object that specifies a PDF document’s form type.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.
See Also:
FormType

save

public java.io.InputStream save()
                         throws java.io.IOException,
                                PDFException
Returns the modified PDF document data stream.

Returns:
A java.io.InputStream that represents the modified PDF document data stream.
Throws:
java.io.IOException - If the returned java.io.InputStream is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

saveAsXDP

public java.io.InputStream saveAsXDP()
                              throws java.io.IOException,
                                     PDFException
Returns the modified PDF document as an XDP data stream.

Returns:
A java.io.InputStream that represents the XDP data stream.
Throws:
java.io.IOException - If the returned java.io.InputStream is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

exportXMP

public java.io.InputStream exportXMP()
                              throws java.io.IOException,
                                     PDFException
Exports the XMP metadata that is associated with a PDF document.

Returns:
A java.io.InputStream object that contains metadata belonging to a PDF document.
Throws:
java.io.IOException - If the returned java.io.InputStream is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

importXMP

public void importXMP(java.io.InputStream src)
               throws java.io.IOException,
                      PDFException
Ensures that the input stream that represents XML is valid and uses it to replace the metadata referenced by the PDF document.

Parameters:
src - A java.io.InputStream containing new metadata.
Throws:
java.io.IOException - If the java.io.InputStream argument is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

importFormData

public void importFormData(java.io.InputStream src)
                    throws java.io.IOException,
                           PDFException
Imports the form data as an XFA or an XFDF data stream.

Parameters:
src - A java.io.InputStream object that represents the data to import.
Throws:
java.io.IOException - If the java.io.InputStream argument is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

exportFormData

public java.io.InputStream exportFormData(FormDataFormat format)
                                   throws java.io.IOException,
                                          PDFException

Exports a form’s data as an XFA or an XFDF data stream as specified by the format parameter. A form’s data can only be exported as an XFA data stream if the getFormType method’s return value is FormType.XML_FORM. For information about determining the form type, see the Developer Guide.

Parameters:
format - A FormDataFormat object that specifies whether the form’s data is exported as an XFA or an XFDF data stream.
Returns:
A java.io.InputStream object that contains the form’s data as an XFDF or an XFA data stream.
Throws:
java.io.IOException - If the returned java.io.InputStream is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

getFileAttachmentNames

public byte[][] getFileAttachmentNames()
                                throws PDFException
Returns an array of names as byte arrays that references file attachments.

Returns:
An array of byte arrays where each byte array represents a file attachment name.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.

importFileAttachment

public void importFileAttachment(byte[] name,
                                 FileAttachment fileAttachment)
                          throws java.io.IOException,
                                 PDFException

Imports the specified FileAttachment object into a PDF document under the given name. If the specified name already exists, the current data is replaced.

Parameters:
name - A byte array that specifies the name of the file attachment.
fileAttachment - A FileAttachment object that is imported into a PDF document.
Throws:
java.io.IOException - If a Java input error occurs.
PDFException - If a PDF exception is raised. For more information, see the API Reference.
See Also:
FileAttachment

exportFileAttachment

public FileAttachment exportFileAttachment(byte[] name)
                                    throws java.io.IOException,
                                           PDFException

Exports data associated with the given name as a FileAttachment object. This method returns null if the name does not exist.

Parameters:
name - A byte array that specifies the file attachment to export.
Returns:
A FileAttachment object that contains the data associated with the specified name.
Throws:
java.io.IOException - If a Java input error occurs.
PDFException - If a PDF exception is raised. For more information, see the API Reference.
See Also:
FileAttachment

deleteFileAttachment

public void deleteFileAttachment(byte[] name)
                          throws PDFException

Deletes a file attachment in a PDF document that is associated with the given name. An exception is not thrown if the specified name does not exist. In this situation, this method does not perform any action.

Parameters:
name - A byte array that specifies the name of the file attachment to delete.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.

importAnnotations

public void importAnnotations(java.io.InputStream xfdfAnnotations)
                       throws java.io.IOException,
                              PDFException
Imports into a PDF document annotations that are represented in an XFDF XML data stream.

Parameters:
xfdfAnnotations - A java.io.InputStream object that represents an XFDF data stream containing annotations to import.
Throws:
java.io.IOException - If the java.io.InputStream argument is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

exportAnnotations

public java.io.InputStream exportAnnotations()
                                      throws java.io.IOException,
                                             PDFException

Exports a PDF document’s annotations as a stream of XFDF XML data. For a complete list of annotations that can be exported, see the Developer Guide.

Returns:
XFDF A java.io.InputStream object that contains annotations as an XFDF XML data stream.
Throws:
java.io.IOException - If the returned java.io.InputStream is invalid.
PDFException - If a PDF exception is raised. For more information, see the API Reference.

deleteAnnotations

public void deleteAnnotations()
                       throws PDFException

Deletes all annotations in a PDF document. This method deletes all annotations in a PDF document that were added using XFDF. Individual annotations cannot be deleted. For a complete list of annotations that can be added using XFDF, see the Developer Guide.

Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.

getImages

public java.util.List getImages()
                         throws PDFException
Returns a list of all images that are referenced by a PDF document.

Returns:
A java.util.List collection object that contains PDFImage objects.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.
See Also:
PDFImage

getWords

public java.util.ListIterator getWords()
                                throws PDFException
Returns a list iterator for accessing the words in the content of the PDF document.

Returns:
A java.util.ListIterator object that can be used for traversing the list of PDFWord objects.
Throws:
PDFException - If a PDF exception is raised. For more information, see the API Reference.
See Also:
PDFWord