|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.qoppa.pdfViewer.hiObjects.AbstractPDFDocument
com.qoppa.pdfProcess.PDFDocument
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.
| Field Summary |
| Fields inherited from interface com.qoppa.pdf.dom.IPDFDocument |
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(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 |
addDocumentListener(IDocumentListener 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). |
void |
appendDocument(PDFDocument appendDoc)
Appends a PDF document to this document. |
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. |
void |
appendPage(PDFPage page)
Appends a page to this document. |
void |
appendPNGAsPage(String pngFileName)
Creates a new page in the PDF document and adds the PNG file to it. |
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 |
clearSecurity(String currentPermissionsPwd)
Clears the security for this 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 index)
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 annotations comments to an output stream in FDF format. |
void |
exportAnnotsAsFDF(String fileName)
Exports annotations 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. |
AcroForm |
getAcroForm()
Returns the AcroForm in this document. |
DocumentInfo |
getDocumentInfo()
Returns a copy of a DocumentInfo object containing the information section of a PDF document (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()
Returns the file for the current pdf file. |
String |
getFileModifiedID()
Returns the file modified ID. |
String |
getFileName()
Returns the name of the pdf document file without the full path. |
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. |
PDFPermissions |
getPermissions()
Returns the permission object for this document. |
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. |
void |
insertPage(PDFPage page,
int index)
Inserts a page into this document at the given index. |
boolean |
isEncrypted()
Returns a flag indicating whether this document is encrypted. |
static PDFDocument |
loadRTF(String rtfFile,
PageFormat pf)
Creates a PDFDocument from an RTF file. |
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 |
setDocumentInfo(DocumentInfo newInfo)
Copies and sets this document's info. |
static boolean |
setKey(String key)
Method to unlock the production version of the library. |
void |
setPageMode(String pageMode)
Changes the value of the page mode viewer preference in the document. |
void |
setPrintSettings(PrintSettings printSettings)
Set the PrintSettings to be used on the next printout. |
void |
setSecurity(String newPermissionsPwd,
String newOpenPwd,
PDFPermissions permissions,
String currentPermissionsPwd,
int encryptType)
Sets the security for this document. |
void |
signDocument(SignatureField signField,
SigningInformation signingInfo)
Signs this document using the given signature field. |
PDFObjectReference |
useFont(Font font)
Internal method used when using fonts in this document. |
| Methods inherited from class com.qoppa.pdfViewer.hiObjects.AbstractPDFDocument |
getDocumentInfo, getLinesWithPositions, getPageMode, getWordsWithPositions |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.qoppa.pdf.dom.IPDFDocument |
getPageMode |
| Constructor Detail |
public PDFDocument(URL url,
IPassword password)
throws PDFException
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.
public PDFDocument(InputStream inStream,
IPassword password)
throws PDFException
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.
public PDFDocument(String fileName,
IPassword password)
throws PDFException
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.
public PDFDocument()
throws PDFException
| Method Detail |
public void appendDocument(PDFDocument appendDoc)
throws PDFException
appendDoc - Document to be appended.
PDFException
public void appendPage(PDFPage page)
throws PDFException
page - The page to add to the document.
PDFException
public void appendTIFFAsPages(String tiffFileName)
throws PDFException,
IOException
tiffFileName - The name of the TIFF file to add to this document.
PDFException
IOException
public void appendTIFFAsPages(InputStream inStream)
throws PDFException,
IOException
inStream - The input stream to read the TIFF image from
PDFException
IOException
public void appendJPEGAsPage(String jpegFileName)
throws PDFException,
IOException
jpegFileName - The name of the JPEG file to add to this document.
PDFException
IOException
public void appendJPEGAsPage(String jpegFileName,
int dpi)
throws PDFException,
IOException
jpegFileName - The name of the JPEG file to add to this document.
PDFException
IOException
public void appendPNGAsPage(String pngFileName)
throws PDFException,
IOException
pngFileName - The name of the PNG file to add to this document.
PDFException
IOException
public void insertPage(PDFPage page,
int index)
throws PDFException
page - The page to add to the document.index - Location where to insert the new page.
PDFException
public void deletePage(int index)
throws PDFException
index - Index of the page to remove.
PDFException
public void exportAnnotsAsFDF(String fileName)
throws PDFException
fileName - The name of the file to export the data to.
PDFException
public void exportAnnotsAsFDF(OutputStream outStream,
String pathToPDFFile)
throws PDFException,
IOException
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
PDFException
IOException
public void exportAnnotsAsXFDF(String fileName)
throws PDFException
fileName - The name of the file to export the data to.
PDFException
public void importAnnotsFDF(InputStream inStream)
throws PDFException
inStream - The input stream in FDF format to read the data from.
PDFException
public void importAnnotsFDF(String fileName)
throws PDFException
fileName - The name of the FDF file to import the data from.
PDFException
public void importAnnotsXFDF(String fileName)
throws PDFException
fileName - The name of the XML file to import the data from.
PDFException
public void importAnnotsXFDF(InputStream inStream)
throws PDFException
inStream - The input stream in XML format to read the data from.
PDFException
public void exportAnnotsAsXFDF(OutputStream outStream,
String pathToPDFFile)
throws PDFException
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
IOException
PDFException
public PDFPage appendNewPage(double pageWidth,
double pageHeight)
throws PDFException
pageWidth - Width of the page in 72DPI.pageHeight - Height of the page in 72DPI.
PDFException
public PDFPage insertNewPage(double pageWidth,
double pageHeight,
int index)
throws PDFException
pageWidth - Width of the page in 72DPI.pageHeight - Height of the page in 72DPI.
PDFException
public void saveDocument(String fileName)
throws IOException,
PDFException
fileName - Name of the file to save the document.
IOException
PDFException
public void saveDocumentAsTIFF(OutputStream outStream,
double resDPI,
String tiffCompression)
throws PDFException,
IOException
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:PDFException
IOException
public void saveDocumentAsTIFF(OutputStream outStream,
TIFFOptions options)
throws PDFException,
IOException
TIFFOptions object as an argument to describe various
TIFF options when saving the file.
outStream - The stream to save the image to.options - Options to use when saving the TIFF file.
PDFException
IOException
public void saveDocument(OutputStream outStream)
throws IOException,
PDFException
outStream - OutputStream where the document will be written to.
IOException
PDFExceptionpublic static boolean setKey(String key)
key - Production key.
public static PDFDocument loadRTF(String rtfFile,
PageFormat pf)
throws PDFException,
IOException,
BadLocationException
rtfFile - - Name of the RTF file.pf - - PageFormat to use when creating pages in the PDF document.
PDFException
IOException
BadLocationExceptionpublic PDFObjectReference useFont(Font font)
public static String getVersion()
public PDFPage getPage(int pageIndex)
pageIndex - Index of the page to return.public Pageable getPageable(PrinterJob pJob)
getPageable in interface IPDFDocumentpJob - PrinterJob object where the Pageable will be used.
public int getPageCount()
getPageCount in interface IPDFDocumentpublic IPDFPage getIPage(int pageIndex)
getIPage in interface IPDFDocumentpageIndex - Index of the page to return.public File getFile()
getFile in interface IPDFDocumentpublic String getFileName()
getFileName in interface IPDFDocumentpublic String getFileOriginalID()
getFileOriginalID in interface IPDFDocumentpublic String getFileModifiedID()
getFileModifiedID in interface IPDFDocument
public Layer addLayer(String name,
int initialState)
throws PDFException
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.
PDFExceptionpublic void setPrintSettings(PrintSettings printSettings)
setPrintSettings in interface IPDFDocumentprintSettings - Settings to use on the next printout.
public void setSecurity(String newPermissionsPwd,
String newOpenPwd,
PDFPermissions permissions,
String currentPermissionsPwd,
int encryptType)
throws PDFException
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, this value can be either PDFPermissions.ENCRYPTION_RC4 or PDFPermissions.ENCRYPTION_AES.
PDFPermissionException - If currentPermissionsPwd is invalid.
PDFException
public void clearSecurity(String currentPermissionsPwd)
throws PDFPermissionException
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.
PDFPermissionException - If currentPermissionsPwd is invalid.public boolean hasOpenPassword()
public boolean isEncrypted()
public int getEncryptionLength()
public String getEncryptionAlgorithm()
public int print(Graphics graphics,
PageFormat pageFormat,
int pageIndex)
throws PrinterException
print in interface PrintablePrinterException
public void print(PrintSettings printSettings)
throws PDFPermissionException,
PrinterException
print in interface IPDFDocumentprintSettings - Print job settings. Use this object to tell jPDFProcess how to print the document. If null, the library will print using default
settings.
PDFPermissionException
PrinterException
public void print(String printerName,
PrintSettings printSettings)
throws PDFPermissionException,
PrinterException
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.
PrinterException - This exception is thrown if the printer is not found or if there is an error while printing.
PDFPermissionException
public void print(String printerName,
PrintSettings printSettings,
PrintRequestAttributeSet printAttrSet)
throws PDFPermissionException,
PrinterException
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.
PrinterException - This exception is thrown if the printer is not found or if there is an error while printing.
PDFPermissionExceptionpublic boolean hasPermissionsPassword()
public final PDFPermissions getPermissions()
getPermissions in interface IPDFDocumentpublic PrintSettings getPrintSettings()
getPrintSettings in interface IPDFDocument
public boolean addEmbeddedFile(File file)
throws IOException,
PDFException
file - The file to embed in the document
IOException
PDFExceptionpublic Vector getEmbeddedFiles()
getEmbeddedFiles in interface IPDFDocument
public boolean removeEmbeddedFile(IEmbeddedFile ef)
throws IOException,
PDFException
ef - the embedded file to remove
IOException
PDFException
public String getText()
throws PDFException
String. Pages are separated with a return char.
getText in interface IPDFDocumentPDFException
public String getText(int pageIndex)
throws PDFException
getText in interface IPDFDocumentpageIndex - is the 0 based page number. pageIndex = 0 is the first page of the document.
PDFException
public Vector getWords()
throws PDFException
Vector of Strings.
PDFException
public Vector getWords(int pageIndex)
throws PDFException
pageIndex - is the 0 based page number. pageIndex = 0 is the first page of the document.
PDFExceptionpublic Bookmark getRootBookmark()
getRootBookmark in interface IPDFDocumentpublic int getLayerCount()
getLayerCount in interface IPDFDocumentpublic Layer getLayer(int layerIndex)
getLayer in interface IPDFDocumentpublic void addDocumentListener(IDocumentListener listener)
addDocumentListener in interface IPDFDocumentpublic void removeDocumentListener(IDocumentListener listener)
removeDocumentListener in interface IPDFDocumentpublic DocumentInfo getDocumentInfo()
getDocumentInfo in interface IPDFDocument
public void setDocumentInfo(DocumentInfo newInfo)
throws PDFException
newInfo - The new document information.
PDFExceptionpublic AcroForm getAcroForm()
getAcroForm in interface IPDFDocument
public void deleteAnnotations()
throws PDFException
PDFException
public void flattenAnnotations(boolean paintNonPrintableAnnots)
throws PDFException
paintNonPrintableAnnots - Flag to indicate whether non-printable annotations should be painted or not.
PDFException
public void flattenFields(boolean paintButtons,
boolean paintNonPrintableFields)
throws PDFException
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.
PDFException
public Bookmark createRootBookmark()
throws PDFException
PDFExceptionpublic String getPDFFileVersion()
public void setPageMode(String pageMode)
throws PDFException
pageMode - The new page mode. This value has to be one of:PDFException
public void signDocument(SignatureField signField,
SigningInformation signingInfo)
throws PDFException
signField - The field to use to sign the document.signingInfo - Information required to sign the document.
PDFException
public Font embedFont(String fileName,
int fontFormat)
throws IOException,
FontFormatException,
PDFException
fileName - Name of the font file.fontFormat - Font format. This can be Font.TRUETYPE_FONT or Font.TYPE1_FONT (if using JDK1.5)
IOException
FontFormatException
PDFException