com.qoppa.pdfProcess
Class PDFDocument

java.lang.Object
  extended by com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
      extended by com.qoppa.pdfProcess.PDFDocument
All Implemented Interfaces:
IPDFDocument, Printable

public class PDFDocument
extends com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument

PDF Document object. This class provides methods to load, modify, print and save PDF documents.

Documents can be loaded from a file, an input stream or a URL. Use the URL constructor when loading a document from a web server or from a servlet.

Author:
Qoppa Software

Nested Class Summary
static class PDFDocument.KeyInfoProcess
           This is the Main-Class for the jPDFProcess.jar that can generate server key requests, validate a key, and display server information.
 
Field Summary
 
Fields inherited from interface com.qoppa.pdf.dom.IPDFDocument
MAGNIFICATION_FIT_ACTUAL, MAGNIFICATION_FIT_HEIGHT, MAGNIFICATION_FIT_PAGE, MAGNIFICATION_FIT_VISIBLE, MAGNIFICATION_FIT_WIDTH, PAGELAYOUT_ONECOLUMN, PAGELAYOUT_SINGLEPAGE, PAGELAYOUT_TWOCOLUMNLEFT, PAGELAYOUT_TWOCOLUMNRIGHT, PAGELAYOUT_TWOPAGELEFT, PAGELAYOUT_TWOPAGERIGHT, PAGEMODE_FULLSCREEN, PAGEMODE_USEATTACHMENTS, PAGEMODE_USENONE, PAGEMODE_USEOC, PAGEMODE_USEOUTLINES, PAGEMODE_USETHUMBS
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PDFDocument()
          Creates a blank PDF document.
PDFDocument(InputStream inStream, IPassword password)
          Creates a PDFDocument object from a PDF InputStream.
PDFDocument(PDFSource source, IPassword password)
          Create a PDFDocument object using a PDFSource interface.
PDFDocument(String fileName, IPassword password)
          Loads a PDF document from a file.
PDFDocument(URL url, IPassword password)
          Loads a PDF document from a URL.
 
Method Summary
 void addAnnotations(Hashtable annotHash)
          This method allows multiple annotations to be added to multiple pages.
 void addDocumentListener(IDocumentListener listener)
          Internal method to keep track of document events.
 void addDocumentModifiedListener(com.qoppa.pdf.objectStore.DocumentModificationListener listener)
          Internal method to keep track of document events.
 boolean addEmbeddedFile(File file)
          Embeds a file into this PDF document.
 Layer addLayer(String name, int initialState)
          Creates and returns a PDF layer (Optional Content Group).
 Layer addLayer(String name, int initialState, boolean showInList)
          Creates and returns a PDF layer (Optional Content Group).
 void appendDocument(PDFDocument appendDoc)
          Appends a PDF document to this document.
 void appendGIFAsPage(InputStream gifStream, int dpi)
          Creates a new page in the PDF document and adds the GIF image to it.
 void appendGIFAsPage(String gifFileName, int dpi)
          Creates a new page in the PDF document and adds the GIF image to it.
 void appendImage(File imageFile)
          This method appends an image (or series of images) to the current document.
 void appendImage(InputStream inStream, String formatName)
          This method appends an image (or series of images) to the current document.
 void appendJPEGAsPage(InputStream inStream)
          Creates a new page in the PDF document and adds the JPEG image to it.
 void appendJPEGAsPage(String jpegFileName)
          Creates a new page in the PDF document and adds the JPEG file to it.
 void appendJPEGAsPage(String jpegFileName, int dpi)
          Creates a new page in the PDF document and adds the JPEG file to it.
 PDFPage appendNewPage(double pageWidth, double pageHeight)
          Creates and appends a new PDFPage to this document.
 PDFPage appendPage(PDFPage page)
          Appends a page to this document.
 void appendPNGAsPage(InputStream inStream)
          Creates a new page in the PDF document and adds a PNG image, read from an input stream, to it.
 void appendPNGAsPage(String pngFileName)
          Creates a new page in the PDF document and adds the PNG file to it.
 void appendTextAsPages(InputStream textStream, TextToPDFSettings settings)
          Creates new pages in the PDF document and adds the text, read from an input stream, to them.
 void appendTextAsPages(String txtFileName, TextToPDFSettings settings)
          Creates new pages in the PDF document and adds the text from an text file to them.
 void appendTIFFAsPages(InputStream inStream)
          Appends the pages in a TIFF image from an input stream to the end of this document.
 void appendTIFFAsPages(String tiffFileName)
          Appends the pages in a TIFF file to the end of this document.
 void clearPasswordPermissions(String currentPermissionsPwd)
          Clears the password permissions for this document.
 void clearSecurity(String currentPermissionsPwd)
          Deprecated. Use clearPasswordPermissions(java.lang.String) instead.
 void clearUsageRights()
          Remove extended permissions from the document.
 Bookmark createRootBookmark()
          Creates a new root bookmark and saves it in the document catalog.
 void deleteAnnotations()
          Delete all annotations in the document.
 void deletePage(int pageIndex)
          Deletes a page from this document.
 Font embedFont(String fileName, int fontFormat)
          Embeds a font in the PDF file.
 void exportAnnotsAsFDF(OutputStream outStream, String pathToPDFFile)
          Export the annotation comments to an output stream in FDF format.
 void exportAnnotsAsFDF(OutputStream outStream, String pathToPDFFile, Set annotSet)
          Export the set of annotation comments to an output stream in FDF format.
 void exportAnnotsAsFDF(String fileName)
          Exports annotation comments in FDF format.
 void exportAnnotsAsFDF(String fileName, Set annotSet)
          Exports a set of annotation comments in FDF format.
 void exportAnnotsAsXFDF(OutputStream outStream, String pathToPDFFile)
          Export annotations comments to an output stream in XFDF format.
 void exportAnnotsAsXFDF(String fileName)
          Exports annotations comments in XFDF format.
 void flattenAnnotations(boolean paintNonPrintableAnnots)
          Flattens the annotations.
 void flattenFields(boolean paintButtons, boolean paintNonPrintableFields)
          Flattens the pdf form fields.
 void flattenFields(boolean paintButtons, boolean paintOnlyImageButtons, boolean paintNonPrintableFields)
          Flattens the pdf form fields.
 AcroForm getAcroForm()
          Returns the AcroForm in this document.
 DocumentInfo getDocumentInfo()
          Returns an object representing the document metadata information (author, title, etc.).
 Vector getEmbeddedFiles()
          Returns the list of embedded files in the document (annotations attachments are not part of the list).
 String getEncryptionAlgorithm()
          Returns the name of the encryption algorithm used to encrypt the document.
 int getEncryptionLength()
          Returns an int representing the number of bits used in the encryption technique.
 File getFile()
          Convenience method that returns the file that the PDF document was loaded from.
 String getFileModifiedID()
          Returns the file modified ID.
 String getFileName()
          Deprecated. Use getPDFSource().getName() instead
 String getFileOriginalID()
          Returns the file original ID.
 IPDFPage getIPage(int pageIndex)
          Internal method, do not use.
 Layer getLayer(int layerIndex)
          Returns a particular PDF layer given its index.
 int getLayerCount()
          Returns the number of PDF layers in this document.
 PDFPage getPage(int pageIndex)
          Returns a page in this document.
 Pageable getPageable(PrinterJob pJob)
          Returns an object that implements Pageable for this PDF document.
 int getPageCount()
          Returns the number of pages in this document.
 String getPDFFileVersion()
          Return the PDF file version for the current document.
 AllPDFPermissions getPDFPermissions()
          Returns the AllPDFPermissions object which encompasses this document's PasswordPermissions, DocMDPPermissions, and UsageRightsPermissions.
 PDFPermissions getPermissions()
          Deprecated. Use getPDFPermissions().getPasswordPermissions() instead.
 PrintSettings getPrintSettings()
          Get the current PrintSettings object.
 Bookmark getRootBookmark()
          Returns the 'root' bookmark.
 String getText()
          Returns the text in the pdf document as a String.
 String getText(int pageIndex)
          Returns text contained in the specified page of the pdf document as a String.
static String getVersion()
          Returns version string for jPDFProcess.
 Vector getWords()
          Returns all words in the pdf document as a Vector of Strings.
 Vector getWords(int pageIndex)
          Returns all words contained in the specified page of the pdf document as a Vector of Strings.
 boolean hasOpenPassword()
          Returns a flag indicating whether this document is encrypted with a 'user' password.
 boolean hasPermissionsPassword()
          Returns a flag indicating whether this document is encrypted with a 'owner' password.
 void importAnnotsFDF(InputStream inStream)
          Import annotations comments from an input stream in FDF format.
 void importAnnotsFDF(String fileName)
          Import annotations comments from a file in FDF Format.
 void importAnnotsXFDF(InputStream inStream)
          Import AcroForm field data from an input stream in XML format.
 void importAnnotsXFDF(String fileName)
          Import Acroform fields data from a file in XML Format.
 PDFPage insertNewPage(double pageWidth, double pageHeight, int index)
          Creates a new PDFPage and inserts it into the document at the given position.
 PDFPage insertPage(PDFPage page, int index)
          Inserts a page into this document at the given index.
 boolean isDocumentModified()
          Returns a flag indicating whether this document has been modified.
 boolean isEncrypted()
          Returns a flag indicating whether this document is encrypted.
 boolean isPortfolio()
          Returns a flag indicating whether this document is a PDF Portfolio.
static PDFDocument loadRTF(String rtfFile, PageFormat pf)
          Creates a PDFDocument from an RTF file.
 void movePage(int currentIndex, int newIndex)
          moves an existing page to a new location.
 int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
          Prints the page.
 void print(PrintSettings printSettings)
          Prints this PDF document.
 void print(String printerName, PrintSettings printSettings)
          Prints this PDF document to the specified printer, by name.
 void print(String printerName, PrintSettings printSettings, PrintRequestAttributeSet printAttrSet)
          Prints this PDF document to the specified printer, by name and passes the print request attribute set to the printer job.
 void removeDocumentListener(IDocumentListener listener)
          Internal method to keep track of document events.
 boolean removeEmbeddedFile(IEmbeddedFile ef)
          Remove a file embedded in this document.
 void saveDocument(OutputStream outStream)
          Saves this document to an output stream.
 void saveDocument(String fileName)
          Saves this document to a file.
 void saveDocumentAsTIFF(OutputStream outStream, double resDPI, String tiffCompression)
          Save the entire document as a multi-page TIFF image to the given OutputStream.
 void saveDocumentAsTIFF(OutputStream outStream, TIFFOptions options)
          Save the entire document as a multi-page TIFF image to an OutputStream.
 void saveDocumentLinearized(OutputStream outputStream)
          Saves this document as a linearized PDF document, for faster web viewing.
 void setInitialPage(int pageNumber)
          Sets the initial page to display.
 void setIsDocumentModified(boolean isModified)
          Sets the document modified flag
static boolean setKey(String key)
          Method to unlock the production version of the library.
 void setMagnification(String magnification)
          Sets the magnification at which to display the initial view.
 void setPageLayout(String pageLayout)
          Changes the value of the page layout key for this document.
 void setPageMode(String pageMode)
          Changes the value of the page mode viewer preference in the document.
 void setPasswordPermissions(String newPermissionsPwd, String newOpenPwd, PasswordPermissions permissions, String currentPermissionsPwd, int encryptType)
          Sets the security for this document.
 void setPDFFileVersion(int majorVersion, int minorVersion)
          Set the PDF file version.
 void setPrintSettings(PrintSettings printSettings)
          Set the PrintSettings to be used on the next printout.
 void setSecurity(String newPermissionsPwd, String newOpenPwd, PasswordPermissions permissions, String currentPermissionsPwd, int encryptType)
          Deprecated. Use the new setPasswordPermission method instead.
 void signDocument(SignatureField signField, SigningInformation signingInfo)
          Signs this document using the given signature field.
 boolean usePermissionsPassword(String password)
          Tells the PDFDocument object that the permissions password is known, so all permissions are granted.
 
Methods inherited from class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
addONOFFEntry, addPrintListener, addToASEntry, calculateNow, clearDocMDP, containsJavaScript, findLayer, findPageFromDictionary, getAnnotationFactory, getDocumentInfo, getDocumentViewPrefs, getInitialPage, getJSHandler, getJSOpenAction, getLinearizationVersionNumber, getLinesWithPositions, getMagnification, getNamedDestination, getNamedJavaScript, getOCGs, getPageLayout, getPageMode, getPDFSource, getResourceManager, getWatermark, getWordsWithPositions, getWordsWithPositions, hasEmptyMandatoryField, isCalculate, isLinearized, removePrintListener, rePromptForJavaScript, setCalculate, setContainsJavaScript, setJavaScriptEnabled, setLinearized, setWatermark, verifySignatures
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFDocument

public PDFDocument()
            throws PDFException
Creates a blank PDF document. Pages can then be added to this document from other documents or by creating blank pages and drawing to them.

Throws:
PDFException

PDFDocument

public PDFDocument(InputStream inStream,
                   IPassword password)
            throws PDFException
Creates a PDFDocument object from a PDF InputStream.

Parameters:
inStream - InputStream to read the pdf document from.
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.
Throws:
PDFException

PDFDocument

public PDFDocument(PDFSource source,
                   IPassword password)
            throws PDFException
Create a PDFDocument object using a PDFSource interface. A PDFSource interface is responsible for providing the PDF binary content to the PDFDocument object. There are default implementations in the com.qoppa.pdf.source package to load PDF documents from files, input streams, byte arrays and URLs. An application can create its own object that implements PDFSource to load a document from a custom source.

Parameters:
source - The source of the PDF content.
password - The password, if any, used to open the document. Set to null if there is no password needed.
Throws:
PDFException

PDFDocument

public PDFDocument(String fileName,
                   IPassword password)
            throws PDFException
Loads a PDF document from a file.

Parameters:
fileName - Name of the PDF file.
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.
Throws:
PDFException

PDFDocument

public PDFDocument(URL url,
                   IPassword password)
            throws PDFException
Loads a PDF document from a URL.

Parameters:
url - URL pointint to the location of the PDF file.
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.
Throws:
PDFException
Method Detail

getVersion

public static String getVersion()
Returns version string for jPDFProcess. If this is the demo version, the return string will contain 'Demo Version' at the end.


loadRTF

public static PDFDocument loadRTF(String rtfFile,
                                  PageFormat pf)
                           throws PDFException,
                                  IOException,
                                  BadLocationException
Creates a PDFDocument from an RTF file. The document will create as many pages as needed to draw the full RTF document.

Parameters:
rtfFile - - Name of the RTF file.
pf - - PageFormat to use when creating pages in the PDF document.
Throws:
PDFException
IOException
BadLocationException

setKey

public static boolean setKey(String key)
Method to unlock the production version of the library.

Parameters:
key - Production key.

addAnnotations

public void addAnnotations(Hashtable annotHash)
                    throws PDFException
This method allows multiple annotations to be added to multiple pages. The hashtable of annotations must have Integers for the keys representing the page index. The values in the hashtable must be Vectors of Annotations.

Parameters:
annotHash - The hashtable of annotations to be added to the document.
Throws:
PDFException

addDocumentListener

public void addDocumentListener(IDocumentListener listener)
Internal method to keep track of document events.

Specified by:
addDocumentListener in interface IPDFDocument
Overrides:
addDocumentListener in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument

addDocumentModifiedListener

public void addDocumentModifiedListener(com.qoppa.pdf.objectStore.DocumentModificationListener listener)
Internal method to keep track of document events.


addEmbeddedFile

public boolean addEmbeddedFile(File file)
                        throws IOException,
                               PDFException
Embeds a file into this PDF document. The file is not embedded as an annotation, it simply gets embedded, so it will be visible in the attachments pane.

Parameters:
file - The file to embed in the document
Returns:
true if the file is embedded successfully
Throws:
IOException
PDFException

addLayer

public Layer addLayer(String name,
                      int initialState)
               throws PDFException
Creates and returns a PDF layer (Optional Content Group). This layer can then be used to add optional content sections to the document by passing it as a parameter to the createGraphics method in PDFPage.

Parameters:
name - The name of the layer. This name will show up on a PDF viewer to turn the layer on or off.
initialState - The initial visibility state of the layer. This determines whether the layer will be visible or not when the PDF document is opened. Valid values for this are Layer.STATE_ON or Layer.STATE_OFF.
Throws:
PDFException

addLayer

public Layer addLayer(String name,
                      int initialState,
                      boolean showInList)
               throws PDFException
Creates and returns a PDF layer (Optional Content Group). This layer can then be used to add optional content sections to the document by passing it as a parameter to the createGraphics method in PDFPage.

Parameters:
name - The name of the layer. This name will show up on a PDF viewer to turn the layer on or off.
initialState - The initial visibility state of the layer. This determines whether the layer will be visible or not when the PDF document is opened. Valid values for this are Layer.STATE_ON or Layer.STATE_OFF.
showInList - Flag to indicate whether this layer should be shown in the list of layers when the document is opened in a PDF viewer
Throws:
PDFException

appendDocument

public void appendDocument(PDFDocument appendDoc)
                    throws PDFException
Appends a PDF document to this document. All the pages in appendDoc will be added at the end of this document.

Parameters:
appendDoc - Document to be appended.
Throws:
PDFException -
  • if this PDFDocument is equal to appendDoc
  • if this PDFDocument has an AcroForm with XFA data and appendDoc has an AcroForm.
  • if appendDoc has an AcroForm with XFA data and this PDFDocument has an AcroForm
    See Also:
    AcroForm.removeXFA()

appendGIFAsPage

public void appendGIFAsPage(InputStream gifStream,
                            int dpi)
                     throws PDFException,
                            IOException
Creates a new page in the PDF document and adds the GIF image to it. The image is read from an input stream. The DPI must be provided because GIF files do not have DPI information embedded in them. PDF standard resolution is 72 DPI.

Parameters:
gifStream - The name of gif file
dpi - The DPI value to use when importing the image.
Throws:
PDFException
IOException

appendGIFAsPage

public void appendGIFAsPage(String gifFileName,
                            int dpi)
                     throws PDFException,
                            IOException
Creates a new page in the PDF document and adds the GIF image to it. The DPI must be provided because GIF files do not have DPI information embedded in them. PDF standard resolution is 72 DPI.

Parameters:
gifFileName - The name of gif file
dpi - The DPI value to use when importing the image.
Throws:
PDFException
IOException

appendImage

public void appendImage(File imageFile)
                 throws PDFException,
                        IOException
This method appends an image (or series of images) to the current document. The method will convert the image(s) to a full PDF page and then add it to the document. If the input image format supports multiple images, such as TIFF, and the file has more than one image, all images will be appended to the document.

Parameters:
imageFile - The input image file. The format of the input file is determined by looking at the extension.
Throws:
PDFException
IOException

appendImage

public void appendImage(InputStream inStream,
                        String formatName)
                 throws IOException,
                        PDFException
This method appends an image (or series of images) to the current document. The method will convert the image(s) to a full PDF page and then add it to the document. If the input image format supports multiple images, such as TIFF, and the file has more than one image, all images will be appended to the document.

Parameters:
inStream - The input stream holding the image contents.
formatName - The name of the format of the input content data. Valid format names are pdf, tiff, tif, png, jpg, jpeg and jpe and are case insensitive.
Throws:
IOException
PDFException

appendJPEGAsPage

public void appendJPEGAsPage(InputStream inStream)
                      throws PDFException,
                             IOException
Creates a new page in the PDF document and adds the JPEG image to it. The method looks at the DPI value in the JPEG image to determine the size of the new page. If not present, the method defaults to 72 DPI.

Parameters:
inStream - the input stream to read the JPEG image from
Throws:
PDFException
IOException

appendJPEGAsPage

public void appendJPEGAsPage(String jpegFileName)
                      throws PDFException,
                             IOException
Creates a new page in the PDF document and adds the JPEG file to it. The method looks at the DPI value in the JPEG image to determine the size of the new page. If not present, the method defaults to 72 DPI.

Parameters:
jpegFileName - The name of the JPEG file to add to this document.
Throws:
PDFException
IOException

appendJPEGAsPage

public void appendJPEGAsPage(String jpegFileName,
                             int dpi)
                      throws PDFException,
                             IOException
Creates a new page in the PDF document and adds the JPEG file to it. The method ignores the DPI value in the file and uses the dpi passed into the method to determine the page size.

Parameters:
jpegFileName - The name of the JPEG file to add to this document.
Throws:
PDFException
IOException

appendNewPage

public PDFPage appendNewPage(double pageWidth,
                             double pageHeight)
                      throws PDFException
Creates and appends a new PDFPage to this document. The pageWidth and pageHeight are specified in 72DPI. The page object can be drawn to by getting a graphics object from it and then drawing to that.

Parameters:
pageWidth - Width of the page in 72DPI.
pageHeight - Height of the page in 72DPI.
Throws:
PDFException

appendPage

public PDFPage appendPage(PDFPage page)
                   throws PDFException
Appends a page to this document. The method creates a copy of this page and then the copy is added to the document. The method returns the newly created PDFPage object. To move a page within the same document, use the movePage(int, int) method.

Parameters:
page - The page to add to the document.
Returns:
The newly created page
Throws:
PDFException -
  • if this PDFDocument has an AcroForm with XFA data and page's PDFDocument has an AcroForm.
  • if page's PDFDocument has an AcroForm with XFA data and this PDFDocument has an AcroForm
    See Also:
    AcroForm.removeXFA()

appendPNGAsPage

public void appendPNGAsPage(InputStream inStream)
                     throws PDFException,
                            IOException
Creates a new page in the PDF document and adds a PNG image, read from an input stream, to it. The method looks at the DPI value in the PNG image to determine the size of the new page. If not present, the method defaults to 72 DPI.

Parameters:
inStream - The input stream to read the PNG image from.
Throws:
PDFException
IOException

appendPNGAsPage

public void appendPNGAsPage(String pngFileName)
                     throws PDFException,
                            IOException
Creates a new page in the PDF document and adds the PNG file to it. The method looks at the DPI value in the PNG image to determine the size of the new page. If not present, the method defaults to 72 DPI.

Parameters:
pngFileName - The name of the PNG file to add to this document.
Throws:
PDFException
IOException

appendTextAsPages

public void appendTextAsPages(InputStream textStream,
                              TextToPDFSettings settings)
                       throws PDFException
Creates new pages in the PDF document and adds the text, read from an input stream, to them.

Parameters:
textStream - The input stream to read the text from.
settings - The object to set the text to PDF settings.
Throws:
PDFException

appendTextAsPages

public void appendTextAsPages(String txtFileName,
                              TextToPDFSettings settings)
                       throws PDFException,
                              IOException
Creates new pages in the PDF document and adds the text from an text file to them.

Parameters:
txtFileName - The name of the text file to add to this document.
settings - The object to set the text to PDF settings.
Throws:
PDFException - , IOException
IOException

appendTIFFAsPages

public void appendTIFFAsPages(InputStream inStream)
                       throws PDFException,
                              IOException
Appends the pages in a TIFF image from an input stream to the end of this document. The method will create a new page for each image in a TIFF file and then draw the image onto the page. The page dimensions will be the same as for the TIFF image, calculated using the TIFF dpi value.

Parameters:
inStream - The input stream to read the TIFF image from
Throws:
PDFException
IOException

appendTIFFAsPages

public void appendTIFFAsPages(String tiffFileName)
                       throws PDFException,
                              IOException
Appends the pages in a TIFF file to the end of this document. The method will create a new page for each image in a TIFF file and then draw the image onto the page. The page dimensions will be the same as for the TIFF image, calculated using the TIFF dpi value.

Parameters:
tiffFileName - The name of the TIFF file to add to this document.
Throws:
PDFException
IOException

clearSecurity

public void clearSecurity(String currentPermissionsPwd)
                   throws PDFException
Deprecated. Use clearPasswordPermissions(java.lang.String) instead.

Clears the security for this document. Calling this method will clear user password, owner password, permissions and encryption.

Parameters:
currentPermissionsPwd - The current permissions password in the document, if any. This password is needed to be able to change the passwords and permissions in a document.
Throws:
PDFPermissionException - If currentPermissionsPwd is invalid.
PDFException

clearPasswordPermissions

public void clearPasswordPermissions(String currentPermissionsPwd)
                              throws PDFException
Clears the password permissions for this document. Calling this method will clear user password, owner password, permissions and encryption.

Parameters:
currentPermissionsPwd - The current permissions password in the document, if any. This password is needed to be able to change the passwords and permissions in a document.
Throws:
PDFPermissionException - If currentPermissionsPwd is invalid.
PDFException

createRootBookmark

public Bookmark createRootBookmark()
                            throws PDFException
Creates a new root bookmark and saves it in the document catalog. When this method is called, any existing bookmarks will be discarded and the new root bookmark will be put in place. Initially, the new root bookmark will have no children (no entries will be displayed in the bookmarks pane when viewing the document).

Returns:
The new root bookmark.
Throws:
PDFException

deleteAnnotations

public void deleteAnnotations()
                       throws PDFException
Delete all annotations in the document.

Throws:
PDFException

deletePage

public void deletePage(int pageIndex)
                throws PDFException
Deletes a page from this document. If the index is out of bounds, (index < 0 or index >= number of pages) this method has no effect on the document.

Parameters:
pageIndex - Index of the page to remove.
Throws:
PDFException

embedFont

public Font embedFont(String fileName,
                      int fontFormat)
               throws IOException,
                      FontFormatException,
                      PDFException
Embeds a font in the PDF file. Use this method to use custom fonts when creating a PDF file. The method returns a Font object that can then be used in the setFont method of Graphics2D. The fonts returned by this method can be used to generate different sizes using deriveFont, but not to generate different styles (bold, italic)

Parameters:
fileName - Name of the font file.
fontFormat - Font format. This can be Font.TRUETYPE_FONT or Font.TYPE1_FONT (if using JDK1.5)
Returns:
Font - The newly created Font object. This can be used in Graphics2d.setFont().
Throws:
IOException
FontFormatException
PDFException

exportAnnotsAsFDF

public void exportAnnotsAsFDF(OutputStream outStream,
                              String pathToPDFFile)
                       throws PDFException,
                              IOException
Export the annotation comments to an output stream in FDF format.

Parameters:
outStream - The output stream to write the data to.
pathToPDFFile - is the relative path from the FDF file to the PDF file name. This parameter can be left null. This parameter is used to fill the PDF file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileName. The file entry is used when you open an FDF file to be able to locate the corresponding PDF file. Example of pathToPDFFile ../qoppa/mydir
Throws:
PDFException
IOException

exportAnnotsAsFDF

public void exportAnnotsAsFDF(OutputStream outStream,
                              String pathToPDFFile,
                              Set annotSet)
                       throws PDFException,
                              IOException
Export the set of annotation comments to an output stream in FDF format.

Parameters:
outStream - The output stream to write the data to.
pathToPDFFile - is the relative path from the FDF file to the PDF file name. This parameter can be left null. This parameter is used to fill the PDF file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileName. The file entry is used when you open an FDF file to be able to locate the corresponding PDF file. Example of pathToPDFFile ../qoppa/mydir
annotSet - The set of annotations to export. If annotSet is not null, only the annotations contained in the set will be exported. Otherwise, all annotations will be exported.
Throws:
PDFException
IOException

exportAnnotsAsFDF

public void exportAnnotsAsFDF(String fileName)
                       throws PDFException
Exports annotation comments in FDF format.

Parameters:
fileName - The name of the file to export the data to.
Throws:
PDFException

exportAnnotsAsFDF

public void exportAnnotsAsFDF(String fileName,
                              Set annotSet)
                       throws PDFException
Exports a set of annotation comments in FDF format.

Parameters:
fileName - The name of the file to export the data to.
annotSet - The set of annotations to export. If annotSet is not null, only the annotations contained in the set will be exported. Otherwise, all annotations will be exported.
Throws:
PDFException

exportAnnotsAsXFDF

public void exportAnnotsAsXFDF(OutputStream outStream,
                               String pathToPDFFile)
                        throws PDFException
Export annotations comments to an output stream in XFDF format.

Parameters:
outStream - The output stream to write the data to.
pathToPDFFile - is the relative path from the fdf file to the pdf file name. This parameter can be left null. This parameter is used to fill the pdf file name entry in the FDF file, the file entry will be set to pathToPDFFile + fileNa The file entry is used when you open an fdf file to be able to locate the corresponding pdf file. Example of pathToPDFFile ../qoppa/mydir
Throws:
IOException
PDFException

exportAnnotsAsXFDF

public void exportAnnotsAsXFDF(String fileName)
                        throws PDFException
Exports annotations comments in XFDF format.

Parameters:
fileName - The name of the file to export the data to.
Throws:
PDFException

flattenAnnotations

public void flattenAnnotations(boolean paintNonPrintableAnnots)
                        throws PDFException
Flattens the annotations. This method paints the content of the annotations directly into the pages and remove the annotations themselves from the document.

Parameters:
paintNonPrintableAnnots - Flag to indicate whether non-printable annotations should be painted or not.
Throws:
PDFException

flattenFields

public void flattenFields(boolean paintButtons,
                          boolean paintNonPrintableFields)
                   throws PDFException
Flattens the pdf form fields. This method paints the content of the fields directly into the pages and remove the fields themselves from the document.

Parameters:
paintButtons - Flag to indicate whether push buttons should be painted or not.
paintNonPrintableFields - Flag to indicate whether non-printable fields should be painted or not.
Throws:
PDFException

flattenFields

public void flattenFields(boolean paintButtons,
                          boolean paintOnlyImageButtons,
                          boolean paintNonPrintableFields)
                   throws PDFException
Flattens the pdf form fields. This method paints the content of the fields directly into the pages and remove the fields themselves from the document.

Parameters:
paintButtons - Flag to indicate whether push buttons should be painted or not.
paintOnlyImageButtons - Flag to indicate that push buttons should only be painted if they have an image (only matters if paintButtons is true)
paintNonPrintableFields - Flag to indicate whether non-printable fields should be painted or not.
Throws:
PDFException

getAcroForm

public AcroForm getAcroForm()
Returns the AcroForm in this document. Returns null if the document has no fields.

Specified by:
getAcroForm in interface IPDFDocument
Overrides:
getAcroForm in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
AcroForm The AcroForm object for this document.

getDocumentInfo

public DocumentInfo getDocumentInfo()
Returns an object representing the document metadata information (author, title, etc.). This is a mutable object, so any changes to this object will be saved with the document.

Specified by:
getDocumentInfo in interface IPDFDocument
Overrides:
getDocumentInfo in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
DocumentInfo Object containing metadata information for the document.

getEmbeddedFiles

public Vector getEmbeddedFiles()
Returns the list of embedded files in the document (annotations attachments are not part of the list). The list is a vector of @see com.qoppa.pdf.IEmbeddedFile.

Specified by:
getEmbeddedFiles in interface IPDFDocument
Overrides:
getEmbeddedFiles in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
Vector a vector of IEmbbededFile

getEncryptionAlgorithm

public String getEncryptionAlgorithm()
Returns the name of the encryption algorithm used to encrypt the document. If the document is not encrypted, the method returns null. Encryptions supported are RC4 and AES.

Returns:
The name of the encryption algorithm.

getEncryptionLength

public int getEncryptionLength()
Returns an int representing the number of bits used in the encryption technique. The integer is the length of the encryption key. It can be 40 for the 40 bits encryption or 128 for 128 bits encryption. -1 indicates that the documents is not encrypted.

Returns:
int The number of bits used in the encryption algorithm.

getFile

public File getFile()
Convenience method that returns the file that the PDF document was loaded from. If the document was not loaded from a file, the method returns null.

Specified by:
getFile in interface IPDFDocument
Overrides:
getFile in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
The file for the pdf document, null if the document was not opened from a file.

getFileModifiedID

public String getFileModifiedID()
Returns the file modified ID. A PDF document contains 2 IDs, an original ID and a modified ID generated by the application that created or modified the document.

Specified by:
getFileModifiedID in interface IPDFDocument
Overrides:
getFileModifiedID in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
The PDF document "modified" ID.

getFileName

public String getFileName()
Deprecated. Use getPDFSource().getName() instead

Returns the name of the pdf document file without the full path. This value is only valid when the document was loaded from a file. The method will return null if the document was loaded from an InputStream or a URL.

Specified by:
getFileName in interface IPDFDocument
Overrides:
getFileName in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
The name of the file that this document was loaded from.

getFileOriginalID

public String getFileOriginalID()
Returns the file original ID. A PDF document contains 2 IDs, an original ID and a modified ID generated by the application that created or modified the document.

Specified by:
getFileOriginalID in interface IPDFDocument
Overrides:
getFileOriginalID in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
The PDF document "original" ID.

getIPage

public IPDFPage getIPage(int pageIndex)
Internal method, do not use.

Specified by:
getIPage in interface IPDFDocument
Overrides:
getIPage in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
pageIndex - Index of the page to return.

getLayer

public Layer getLayer(int layerIndex)
Returns a particular PDF layer given its index.

Specified by:
getLayer in interface IPDFDocument
Overrides:
getLayer in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
A reference to the PDF layer.

getLayerCount

public int getLayerCount()
Returns the number of PDF layers in this document.

Specified by:
getLayerCount in interface IPDFDocument
Overrides:
getLayerCount in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
Number of layers in the document.

getPage

public PDFPage getPage(int pageIndex)
Returns a page in this document.

Parameters:
pageIndex - Index of the page to return.

getPageable

public Pageable getPageable(PrinterJob pJob)
Returns an object that implements Pageable for this PDF document. The method takes a PrinterJob object as a parameter because information about the printer is needed in order to fulfill the Pageable interface properly.

Specified by:
getPageable in interface IPDFDocument
Overrides:
getPageable in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
pJob - PrinterJob object where the Pageable will be used.
Returns:
Object that implements the Pageable interface.

getPageCount

public int getPageCount()
Returns the number of pages in this document.

Specified by:
getPageCount in interface IPDFDocument
Overrides:
getPageCount in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument

getPDFFileVersion

public String getPDFFileVersion()
Return the PDF file version for the current document.

Returns:
The version of the PDF document.

getPrintSettings

public PrintSettings getPrintSettings()
Get the current PrintSettings object.

Specified by:
getPrintSettings in interface IPDFDocument
Overrides:
getPrintSettings in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument

getRootBookmark

public Bookmark getRootBookmark()
Returns the 'root' bookmark. Bookmarks form a tree structure in a document.

Specified by:
getRootBookmark in interface IPDFDocument
Overrides:
getRootBookmark in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
Bookmark The root bookmark for this document.

getText

public String getText()
               throws PDFException
Returns the text in the pdf document as a String. Pages are separated with a return char.

Specified by:
getText in interface IPDFDocument
Overrides:
getText in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
Text contained in the pdf document as String.
Throws:
PDFException

getText

public String getText(int pageIndex)
               throws PDFException
Returns text contained in the specified page of the pdf document as a String.

Specified by:
getText in interface IPDFDocument
Overrides:
getText in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
pageIndex - is the 0 based page number. pageIndex = 0 is the first page of the document.
Returns:
Text contained in the specified page as a String.
Throws:
PDFException

getWords

public Vector getWords()
                throws PDFException
Returns all words in the pdf document as a Vector of Strings.

Returns:
Words contained in the pdf document as a Vector of Strings.
Throws:
PDFException

getWords

public Vector getWords(int pageIndex)
                throws PDFException
Returns all words contained in the specified page of the pdf document as a Vector of Strings.

Overrides:
getWords in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
pageIndex - is the 0 based page number. pageIndex = 0 is the first page of the document.
Returns:
Words contained in the specified page as a Vector of Strings.
Throws:
PDFException

hasOpenPassword

public boolean hasOpenPassword()
Returns a flag indicating whether this document is encrypted with a 'user' password.

Returns:
boolean true if the document is encrypted with an open password, false otherwise.

hasPermissionsPassword

public boolean hasPermissionsPassword()
Returns a flag indicating whether this document is encrypted with a 'owner' password.

Returns:
boolean true if the document is encrypted with a permissions password, false otherwise.

importAnnotsFDF

public void importAnnotsFDF(InputStream inStream)
                     throws PDFException
Import annotations comments from an input stream in FDF format.

Parameters:
inStream - The input stream in FDF format to read the data from.
Throws:
PDFException

importAnnotsFDF

public void importAnnotsFDF(String fileName)
                     throws PDFException
Import annotations comments from a file in FDF Format.

Parameters:
fileName - The name of the FDF file to import the data from.
Throws:
PDFException

importAnnotsXFDF

public void importAnnotsXFDF(InputStream inStream)
                      throws PDFException
Import AcroForm field data from an input stream in XML format.

Parameters:
inStream - The input stream in XML format to read the data from.
Throws:
PDFException

importAnnotsXFDF

public void importAnnotsXFDF(String fileName)
                      throws PDFException
Import Acroform fields data from a file in XML Format.

Parameters:
fileName - The name of the XML file to import the data from.
Throws:
PDFException

insertNewPage

public PDFPage insertNewPage(double pageWidth,
                             double pageHeight,
                             int index)
                      throws PDFException
Creates a new PDFPage and inserts it into the document at the given position. The pageWidth and pageHeight are specified in 72DPI. The page object can be drawn to by getting a graphics object from it and then drawing to that.

Parameters:
pageWidth - Width of the page in 72DPI.
pageHeight - Height of the page in 72DPI.
Throws:
PDFException

insertPage

public PDFPage insertPage(PDFPage page,
                          int index)
                   throws PDFException
Inserts a page into this document at the given index. A copy of the page is made and the copy is then added to the document. The method returns the newly created PDFPage object. To move a page within the same document, use the movePage(int, int) method.

If the index is less than 0, the page is inserted as the first page. If the index is greater than the number of pages in the document, the page is appended to the document.

Parameters:
page - The page to add to the document.
index - Location where to insert the new page.
Returns:
The newly created page
Throws:
PDFException -
  • if this PDFDocument has an AcroForm with XFA data and page's PDFDocument has an AcroForm.
  • if page's PDFDocument has an AcroForm with XFA data and this PDFDocument has an AcroForm
    See Also:
    AcroForm.removeXFA()

isDocumentModified

public boolean isDocumentModified()
Returns a flag indicating whether this document has been modified.

Returns:
boolean true if the document is modified, false otherwise.

isEncrypted

public boolean isEncrypted()
Returns a flag indicating whether this document is encrypted.

Returns:
boolean true if the document is encrypted with a user password, false otherwise.

isPortfolio

public boolean isPortfolio()
                    throws PDFException
Returns a flag indicating whether this document is a PDF Portfolio.

Returns:
true if the PDF is a portfolio, false otherwise.
Throws:
PDFException

movePage

public void movePage(int currentIndex,
                     int newIndex)
              throws PDFException
moves an existing page to a new location.

Parameters:
currentIndex - The current index of the page to move.
newIndex - The location to move the page.
Throws:
PDFException

print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int pageIndex)
          throws PrinterException
Prints the page. This method fulfills the Printable interface and usually gets called by PrinterJob when printing the document.

Specified by:
print in interface Printable
Overrides:
print in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Throws:
PrinterException

print

public void print(PrintSettings printSettings)
           throws PDFPermissionException,
                  PrinterException
Prints this PDF document. This method will prompt the user with the printer dialog and then print the document.

If more control is desired when printing, the calling application can create its own PrinterJob and then use this object as a Printable or a Pageable in the PrinterJob before initiating the printout.

Specified by:
print in interface IPDFDocument
Overrides:
print in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
printSettings - Print job settings. Use this object to tell jPDFProcess how to print the document. If null, the library will print using default settings.
Throws:
PDFPermissionException
PrinterException

print

public void print(String printerName,
                  PrintSettings printSettings)
           throws PDFPermissionException,
                  PrinterException
Prints this PDF document to the specified printer, by name. If the printerName parameter is null, this method will print to the default printer. This method can only be called if using Java 1.4.2 or higher as it needs PrintServices, which were only implemented starting on 1.4.

If finer control of printing is necessary, the PDFPrint object implements both Printable and Pageable (through its getPageable method). The host application can then create its own PrinterJob and set any settings necessary, then call either setPageable or setPrintable and then start the print job.

Parameters:
printSettings - Print job settings. Use this object to tell the library how to print the document. If null, the library will print using default settings.
printerName - The name of the printer to print to. If this parameter is set to null, the method will print to the default printer.
Throws:
PrinterException - This exception is thrown if the printer is not found or if there is an error while printing.
PDFPermissionException

print

public void print(String printerName,
                  PrintSettings printSettings,
                  PrintRequestAttributeSet printAttrSet)
           throws PDFPermissionException,
                  PrinterException
Prints this PDF document to the specified printer, by name and passes the print request attribute set to the printer job. If the printerName parameter is null, this method will print to the default printer. If the printAttrSet parameter is null, this is equivalent to calling print (printerName, printSettings). This method can only be called if using Java 1.4.2 or higher as it needs PrintServices, which were only implemented starting on 1.4.

If finer control of printing is necessary, the PDFPrint object implements both Printable and Pageable (through its getPageable method). The host application can then create its own PrinterJob and set any settings necessary, then call either setPageable or setPrintable and then start the print job.

Overrides:
print in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
printSettings - Print job settings. Use this object to tell the library how to print the document. If null, the library will print using default settings.
printerName - The name of the printer to print to. If this parameter is set to null, the method will print to the default printer.
printAttrSet - The attribute set to pass to the printer. This parameter simply gets passed through to the printer job to set options such as the media tray, chromaticity and others. If null is passed, the print job will use default attributes.
Throws:
PrinterException - This exception is thrown if the printer is not found or if there is an error while printing.
PDFPermissionException

removeDocumentListener

public void removeDocumentListener(IDocumentListener listener)
Internal method to keep track of document events.

Specified by:
removeDocumentListener in interface IPDFDocument
Overrides:
removeDocumentListener in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument

removeEmbeddedFile

public boolean removeEmbeddedFile(IEmbeddedFile ef)
                           throws IOException,
                                  PDFException
Remove a file embedded in this document. The list of embedded files can be obtained through the getEmbeddedFiles() method.

Parameters:
ef - the embedded file to remove
Returns:
true if the embedded file was removed, false if not
Throws:
IOException
PDFException

saveDocument

public void saveDocument(OutputStream outStream)
                  throws IOException,
                         PDFException
Saves this document to an output stream.

Parameters:
outStream - OutputStream where the document will be written to.
Throws:
IOException
PDFException

saveDocument

public void saveDocument(String fileName)
                  throws IOException,
                         PDFException
Saves this document to a file.

Parameters:
fileName - Name of the file to save the document.
Throws:
IOException
PDFException

saveDocumentAsTIFF

public void saveDocumentAsTIFF(OutputStream outStream,
                               double resDPI,
                               String tiffCompression)
                        throws PDFException,
                               IOException
Save the entire document as a multi-page TIFF image to the given OutputStream. dpi is the resolution in DPI used to render the pages, 72 is the native PDF resolution and is equivalent to 100% scale.

If any of the CCITT compression algorithms are used, the image will be converted to black and white before saving.

Parameters:
outStream - The stream to save the image to.
resDPI - Dots per inch at which to render the image, 72 is the native PDF resolution and is equivalent to 100% scale..
tiffCompression - The type of TIFF compression to use. This value needs to be one of these predefined values:

TIFFOptions.TIFF_DEFLATE - Deflate lossless compression (Zip-in-TIFF)
TIFFOptions.TIFF_CCITT_RLE - CCITT Modified Huffman RLE
TIFFOptions.TIFF_CCITT_T4 - CCITT Group 3 fax encoding
TIFFOptions.TIFF_CCITT_T6 - CCITT Group 4 fax encoding
TIFFOptions.TIFF_JPEG - JPEG-in-TIFF compression.
TIFFOptions.TIFF_LZW - LZW Compression
TIFFOptions.TIFF_PACKBITS - Byte-oriented run-length encoding "PackBits" compression.
TIFFOptions.TIFF_ZLIB - ZLib Compression.
TIFFOptions.TIFF_NO_COMPRESSION - No compression.
Throws:
PDFException
IOException

saveDocumentAsTIFF

public void saveDocumentAsTIFF(OutputStream outStream,
                               TIFFOptions options)
                        throws PDFException,
                               IOException
Save the entire document as a multi-page TIFF image to an OutputStream. This method takes a TIFFOptions object as an argument to describe various TIFF options when saving the file.

Parameters:
outStream - The stream to save the image to.
options - Options to use when saving the TIFF file.
Throws:
PDFException
IOException

setInitialPage

public void setInitialPage(int pageNumber)
                    throws PDFException
Sets the initial page to display.

Parameters:
pageNumber - The page number. Use 0 for first page.
Throws:
PDFException

setIsDocumentModified

public void setIsDocumentModified(boolean isModified)
Sets the document modified flag


setMagnification

public void setMagnification(String magnification)
                      throws PDFException
Sets the magnification at which to display the initial view.

Parameters:
magnification - A string magnification. This value has to be one of:
IPDFDocument.MAGNIFICATION_FIT_WIDTH: Display wtih the page magnified just enough to fit the entire width of the page within the window.
IPDFDocument.MAGNIFICATION_FIT_VISIBLE: Display with the page magnified just enoguh to fit the entire width of its bouding box within the window.
IPDFDocument.MAGNIFICATION_FIT_HEIGHT: Display with the page magnified just enough to fit the entire height of the page within the window.
IPDFDocument.MAGNIFICATION_FIT_PAGE: Display with the page magnified just enough to fit the entire page within the window both horizontally and vertically .
IPDFDocument.MAGNIFICATION_FIT_ACTUAL: Display the page with 100% magnification.

A String value of a number, ex. "125"
A null value to clear the magnification
Throws:
PDFException

setPageLayout

public void setPageLayout(String pageLayout)
                   throws PDFException
Changes the value of the page layout key for this document. This determines the layout of the page when initially opened.

Parameters:
pageLayout - The new page mode. This value has to be one of:
IPDFDocument.PAGELAYOUT_SINGLEPAGE: Display one page at a time.
IPDFDocument.PAGELAYOUT_ONECOLUMN: Display the page in one column (single page continuous).
IPDFDocument.PAGELAYOUT_TWOCOLUMNLEFT: Display the page in two columns (two facing continuous).
IPDFDocuemnt.PAGELAYOUT_TWOPAGELEFT: Display two pages at a time (two facing).
Throws:
PDFException

setPageMode

public void setPageMode(String pageMode)
                 throws PDFException
Changes the value of the page mode viewer preference in the document. The page mode is used when the document is opened in a PDF Viewer.

Parameters:
pageMode - The new page mode. This value has to be one of:
PAGEMODE_USENONE: Neither document outline nor thumbnail images are visible.
PAGEMODE_USEOUTLINES: Document outline visible.
PAGEMODE_USETHUMBS: Thumbnail images visible.
PAGEMODE_FULLSCREEN: Full screen mode, with no menu bar, window controls, or any other window visible.
Throws:
PDFException

setPrintSettings

public void setPrintSettings(PrintSettings printSettings)
Set the PrintSettings to be used on the next printout.

Specified by:
setPrintSettings in interface IPDFDocument
Overrides:
setPrintSettings in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Parameters:
printSettings - Settings to use on the next printout.

setSecurity

public void setSecurity(String newPermissionsPwd,
                        String newOpenPwd,
                        PasswordPermissions permissions,
                        String currentPermissionsPwd,
                        int encryptType)
                 throws PDFException
Deprecated. Use the new setPasswordPermission method instead.

Sets the security for this document. If the open password is null, the user won't have to enter a password to open the document. If the permissions password is null, any user can change the permissions on the document. The document will be encrypted regardless. To clear the encryption, call the clearSecurity method.

Parameters:
newPermissionsPwd - The document's permissions password.
newOpenPwd - The document's open password.
permissions - Permission object.
currentPermissionsPwd - The current permissions password in the document, if any. This password is needed to be able to change the passwords and permissions in a document.
encryptType - The encryption type to use: PDFPermissions.ENCRYPTION_RC4_128, PDFPermissions.ENCRYPTION_RC4_128, PDFPermissions.ENCRYPTION_AES_128, etc...
Throws:
PDFPermissionException - If currentPermissionsPwd is invalid.
PDFException

setPasswordPermissions

public void setPasswordPermissions(String newPermissionsPwd,
                                   String newOpenPwd,
                                   PasswordPermissions permissions,
                                   String currentPermissionsPwd,
                                   int encryptType)
                            throws PDFException
Sets the security for this document. If the open password is null, the user won't have to enter a password to open the document. If the permissions password is null, any user can change the permissions on the document. The document will be encrypted regardless. To clear the encryption, call the clearPasswordPermissions method.

Parameters:
newPermissionsPwd - The document's permissions password.
newOpenPwd - The document's open password.
permissions - Permission object.
currentPermissionsPwd - The current permissions password in the document, if any. This password is needed to be able to change the passwords and permissions in a document.
encryptType - The encryption type to use: PasswordPermissions.ENCRYPTION_RC4_128, PasswordPermissions.ENCRYPTION_RC4_128, PasswordPermissions.ENCRYPTION_AES_128, etc...
Throws:
PDFPermissionException - If currentPermissionsPwd is invalid.
PDFException

getPermissions

public final PDFPermissions getPermissions()
Deprecated. Use getPDFPermissions().getPasswordPermissions() instead.

Returns the permission object for this document. A new permissions object with all permissions is returned if the document is not encrypted.

Specified by:
getPermissions in interface IPDFDocument
Overrides:
getPermissions in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
The permission object.

getPDFPermissions

public final AllPDFPermissions getPDFPermissions()
Returns the AllPDFPermissions object which encompasses this document's PasswordPermissions, DocMDPPermissions, and UsageRightsPermissions.

Specified by:
getPDFPermissions in interface IPDFDocument
Overrides:
getPDFPermissions in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Returns:
An AllPDFPermissions object that contains permission flags for this document.

clearUsageRights

public void clearUsageRights()
                      throws PDFException
Remove extended permissions from the document.

Overrides:
clearUsageRights in class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
Throws:
PDFException

signDocument

public void signDocument(SignatureField signField,
                         SigningInformation signingInfo)
                  throws PDFException
Signs this document using the given signature field.

Parameters:
signField - The field to use to sign the document.
signingInfo - Information required to sign the document.
Throws:
PDFException
See Also:
SignatureAppearance

usePermissionsPassword

public boolean usePermissionsPassword(String password)
                               throws PDFException
Tells the PDFDocument object that the permissions password is known, so all permissions are granted. This method is here as a convenience so that if the owner password is known, the host application does not have to clear the security, make changes to the document, and then restore the security.

Parameters:
password - The permissions password
Returns:
true if the password was validated or the document is not encrypted
Throws:
PDFException

saveDocumentLinearized

public void saveDocumentLinearized(OutputStream outputStream)
                            throws PDFException,
                                   IOException
Saves this document as a linearized PDF document, for faster web viewing.

Parameters:
outputStream - The output stream to write the PDF contents to.
Throws:
PDFException
IOException

setPDFFileVersion

public void setPDFFileVersion(int majorVersion,
                              int minorVersion)
Set the PDF file version. This method does not check for valid PDF versions, please consult the current PDF reference to make sure that the version set is a valid version. The method takes two arguments, one for the major part of the version and the second for the minor. When writing the PDF, these two parts are put together as follows:

majorVersion.minorVersion

Parameters:
majorVersion - The integer part of the version
minorVersion - The decimal part of the version