Java Doc for PDDocument.java in  » PDF » PDFBox-0.7.3 » org » pdfbox » pdmodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » PDFBox 0.7.3 » org.pdfbox.pdmodel 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.pdfbox.pdmodel.PDDocument

PDDocument
public class PDDocument implements Pageable(Code)
This is the in-memory representation of the PDF document. You need to call close() on this object when you are done using it!!
author:
   Ben Litchfield
version:
   $Revision: 1.43 $



Constructor Summary
public  PDDocument()
     Constructor, creates a new PDF Document with no pages.
public  PDDocument(COSDocument doc)
     Constructor that uses an existing document.

Method Summary
public  voidaddPage(PDPage page)
     This will add a page to the document.
public  voidclearWillEncryptWhenSaving()
     This shoule only be called by the COSWriter after encryption has completed.
public  voidclose()
     This will close the underlying COSDocument object.
public  voiddecrypt(String password)
     This will decrypt a document.
public  voidencrypt(String ownerPassword, String userPassword)
     This will mark a document to be encrypted.
public  AccessPermissiongetCurrentAccessPermission()
     Returns the access permissions granted when the document was decrypted.
public  COSDocumentgetDocument()
     This will get the low level document.
public  PDDocumentCataloggetDocumentCatalog()
     This will get the document CATALOG.
public  PDDocumentInformationgetDocumentInformation()
     This will get the document info dictionary.
public  PDEncryptionDictionarygetEncryptionDictionary()
     This will get the encryption dictionary for this document.
public  intgetNumberOfPages()
    
public  StringgetOwnerPasswordForEncryption()
     The owner password that was passed into the encrypt method.
public  intgetPageCount()
     This will return the total page count of the PDF document.
public  PageFormatgetPageFormat(int pageIndex)
    
public  PrintablegetPrintable(int pageIndex)
    
public  SecurityHandlergetSecurityHandler()
     Get the security handler that is used for document encryption.
public  StringgetUserPasswordForEncryption()
     The user password that was passed into the encrypt method.
public  PDPageimportPage(PDPage page)
     This will import and copy the contents from another location.
public  booleanisEncrypted()
     This will tell if this document is encrypted or not.
public  booleanisOwnerPassword(String password)
     This will determine if this is the owner password.
public  booleanisUserPassword(String password)
     This will determine if this is the user password.
public static  PDDocumentload(URL url)
     This will load a document from a url.
Parameters:
  url - The url to load the PDF from.
public static  PDDocumentload(URL url, RandomAccess scratchFile)
     This will load a document from a url.
Parameters:
  url - The url to load the PDF from.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document.
public static  PDDocumentload(String filename)
     This will load a document from a file.
Parameters:
  filename - The name of the file to load.
public static  PDDocumentload(String filename, RandomAccess scratchFile)
     This will load a document from a file.
Parameters:
  filename - The name of the file to load.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document.
public static  PDDocumentload(File file)
     This will load a document from a file.
Parameters:
  file - The name of the file to load.
public static  PDDocumentload(File file, RandomAccess scratchFile)
     This will load a document from a file.
Parameters:
  file - The name of the file to load.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document.
public static  PDDocumentload(InputStream input)
     This will load a document from an input stream.
Parameters:
  input - The stream that contains the document.
public static  PDDocumentload(InputStream input, RandomAccess scratchFile)
     This will load a document from an input stream.
Parameters:
  input - The stream that contains the document.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document.
public  voidopenProtection(DecryptionMaterial pm)
     Tries to decrypt the document in memory using the provided decryption material.
public  voidprint()
     This will send the PDF document to a printer.
public  voidprotect(ProtectionPolicy pp)
     Protects the document with the protection policy pp.
public  booleanremovePage(PDPage page)
     Remove the page from the document.
Parameters:
  page - The page to remove from the document.
public  booleanremovePage(int pageNumber)
     Remove the page from the document.
Parameters:
  pageNumber - 0 based index to page number.
public  voidsave(String fileName)
     This will save this document to the filesystem.
public  voidsave(OutputStream output)
     This will save the document to an output stream.
public  voidsetDocumentInformation(PDDocumentInformation info)
     This will set the document information for this document.
public  voidsetEncryptionDictionary(PDEncryptionDictionary encDictionary)
     This will set the encryption dictionary for this document.
public  voidsilentPrint()
     This will send the PDF to the default printer without prompting the user for any printer settings.
public  booleanwasDecryptedWithOwnerPassword()
     This will tell if the document was decrypted with the master password.
public  booleanwillEncryptWhenSaving()
     Internal method do determine if the document will be encrypted when it is saved.


Constructor Detail
PDDocument
public PDDocument() throws IOException(Code)
Constructor, creates a new PDF Document with no pages. You need to add at least one page for the document to be valid.
throws:
  IOException - If there is an error creating this document.



PDDocument
public PDDocument(COSDocument doc)(Code)
Constructor that uses an existing document. The COSDocument that is passed in must be valid.
Parameters:
  doc - The COSDocument that this document wraps.




Method Detail
addPage
public void addPage(PDPage page)(Code)
This will add a page to the document. This is a convenience method, that will add the page to the root of the hierarchy and set the parent of the page to the root.
Parameters:
  page - The page to add to the document.



clearWillEncryptWhenSaving
public void clearWillEncryptWhenSaving()(Code)
This shoule only be called by the COSWriter after encryption has completed.



close
public void close() throws IOException(Code)
This will close the underlying COSDocument object.
throws:
  IOException - If there is an error releasing resources.



decrypt
public void decrypt(String password) throws CryptographyException, IOException, InvalidPasswordException(Code)
This will decrypt a document. This method is provided for compatibility reasons only. User should use the new security layer instead and the openProtection method especially.
Parameters:
  password - Either the user or owner password.
throws:
  CryptographyException - If there is an error decrypting the document.
throws:
  IOException - If there is an error getting the stream data.
throws:
  InvalidPasswordException - If the password is not a user or owner password.



encrypt
public void encrypt(String ownerPassword, String userPassword) throws CryptographyException, IOException(Code)
This will mark a document to be encrypted. The actual encryption will occur when the document is saved. This method is provided for compatibility reasons only. User should use the new security layer instead and the openProtection method especially.
Parameters:
  ownerPassword - The owner password to encrypt the document.
Parameters:
  userPassword - The user password to encrypt the document.
throws:
  CryptographyException - If an error occurs during encryption.
throws:
  IOException - If there is an error accessing the data.



getCurrentAccessPermission
public AccessPermission getCurrentAccessPermission()(Code)
Returns the access permissions granted when the document was decrypted. If the document was not decrypted this method returns the access permission for a document owner (ie can do everything). The returned object is in read only mode so that permissions cannot be changed. Methods providing access to content should rely on this object to verify if the current user is allowed to proceed. the access permissions for the current user on the document.



getDocument
public COSDocument getDocument()(Code)
This will get the low level document. The document that this layer sits on top of.



getDocumentCatalog
public PDDocumentCatalog getDocumentCatalog()(Code)
This will get the document CATALOG. This is guaranteed to not return null. The documents /Root dictionary



getDocumentInformation
public PDDocumentInformation getDocumentInformation()(Code)
This will get the document info dictionary. This is guaranteed to not return null. The documents /Info dictionary



getEncryptionDictionary
public PDEncryptionDictionary getEncryptionDictionary() throws IOException(Code)
This will get the encryption dictionary for this document. This will still return the parameters if the document was decrypted. If the document was never encrypted then this will return null. As the encryption architecture in PDF documents is plugable this returns an abstract class, but the only supported subclass at this time is a PDStandardEncryption object. The encryption dictionary(most likely a PDStandardEncryption object)
throws:
  IOException - If there is an error determining which security handler to use.



getNumberOfPages
public int getNumberOfPages()(Code)



getOwnerPasswordForEncryption
public String getOwnerPasswordForEncryption()(Code)
The owner password that was passed into the encrypt method. You should never use this method. This will not longer be valid once encryption has occured. The owner password passed to the encrypt method.



getPageCount
public int getPageCount()(Code)
This will return the total page count of the PDF document. Note: This method is deprecated in favor of the getNumberOfPages method. The getNumberOfPages is a required interface method of the Pageable interface. This method will be removed in a future version of PDFBox!! The total number of pages in the PDF document.



getPageFormat
public PageFormat getPageFormat(int pageIndex)(Code)



getPrintable
public Printable getPrintable(int pageIndex)(Code)



getSecurityHandler
public SecurityHandler getSecurityHandler()(Code)
Get the security handler that is used for document encryption. The handler used to encrypt/decrypt the document.



getUserPasswordForEncryption
public String getUserPasswordForEncryption()(Code)
The user password that was passed into the encrypt method. You should never use this method. This will not longer be valid once encryption has occured. The user password passed to the encrypt method.



importPage
public PDPage importPage(PDPage page) throws IOException(Code)
This will import and copy the contents from another location. Currently the content stream is stored in a scratch file. The scratch file is associated with the document. If you are adding a page to this document from another document and want to copy the contents to this document's scratch file then use this method otherwise just use the addPage method.
Parameters:
  page - The page to import. The page that was imported.
throws:
  IOException - If there is an error copying the page.



isEncrypted
public boolean isEncrypted()(Code)
This will tell if this document is encrypted or not. true If this document is encrypted.



isOwnerPassword
public boolean isOwnerPassword(String password) throws IOException, CryptographyException(Code)
This will determine if this is the owner password. This only applies when the document is encrypted and uses standard encryption.
Parameters:
  password - The plain text owner password. true If the password passed in matches the owner password used to encrypt the document.
throws:
  IOException - If there is an error determining if it is the user password.
throws:
  CryptographyException - If there is an error in the encryption algorithms.



isUserPassword
public boolean isUserPassword(String password) throws IOException, CryptographyException(Code)
This will determine if this is the user password. This only applies when the document is encrypted and uses standard encryption.
Parameters:
  password - The plain text user password. true If the password passed in matches the user password used to encrypt the document.
throws:
  IOException - If there is an error determining if it is the user password.
throws:
  CryptographyException - If there is an error in the encryption algorithms.



load
public static PDDocument load(URL url) throws IOException(Code)
This will load a document from a url.
Parameters:
  url - The url to load the PDF from. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(URL url, RandomAccess scratchFile) throws IOException(Code)
This will load a document from a url.
Parameters:
  url - The url to load the PDF from.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(String filename) throws IOException(Code)
This will load a document from a file.
Parameters:
  filename - The name of the file to load. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(String filename, RandomAccess scratchFile) throws IOException(Code)
This will load a document from a file.
Parameters:
  filename - The name of the file to load.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(File file) throws IOException(Code)
This will load a document from a file.
Parameters:
  file - The name of the file to load. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(File file, RandomAccess scratchFile) throws IOException(Code)
This will load a document from a file.
Parameters:
  file - The name of the file to load.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(InputStream input) throws IOException(Code)
This will load a document from an input stream.
Parameters:
  input - The stream that contains the document. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



load
public static PDDocument load(InputStream input, RandomAccess scratchFile) throws IOException(Code)
This will load a document from an input stream.
Parameters:
  input - The stream that contains the document.
Parameters:
  scratchFile - A location to store temp PDFBox data for this document. The document that was loaded.
throws:
  IOException - If there is an error reading from the stream.



openProtection
public void openProtection(DecryptionMaterial pm) throws BadSecurityHandlerException, IOException, CryptographyException(Code)
Tries to decrypt the document in memory using the provided decryption material.
See Also:   org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial
See Also:   org.pdfbox.pdmodel.encryption.PublicKeyDecryptionMaterial
Parameters:
  pm - The decryption material (password or certificate).
throws:
  BadSecurityHandlerException - If there is an error during decryption.
throws:
  IOException - If there is an error reading cryptographic information.
throws:
  CryptographyException - If there is an error during decryption.



print
public void print() throws PrinterException(Code)
This will send the PDF document to a printer. The printing functionality depends on the org.pdfbox.pdfviewer.PageDrawer functionality. The PageDrawer is a work in progress and some PDFs will print correctly and some will not. This is a convenience method to create the java.awt.print.PrinterJob. The PDDocument implements the java.awt.print.Pageable interface and PDPage implementes the java.awt.print.Printable interface, so advanced printing capabilities can be done by using those interfaces instead of this method.
throws:
  PrinterException - If there is an error while sending the PDF tothe printer, or you do not have permissions to print this document.



protect
public void protect(ProtectionPolicy pp) throws BadSecurityHandlerException(Code)
Protects the document with the protection policy pp. The document content will be really encrypted when it will be saved. This method only marks the document for encryption.
See Also:   org.pdfbox.pdmodel.encryption.StandardProtectionPolicy
See Also:   org.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy
Parameters:
  pp - The protection policy.
throws:
  BadSecurityHandlerException - If there is an error during protection.



removePage
public boolean removePage(PDPage page)(Code)
Remove the page from the document.
Parameters:
  page - The page to remove from the document. true if the page was found false otherwise.



removePage
public boolean removePage(int pageNumber)(Code)
Remove the page from the document.
Parameters:
  pageNumber - 0 based index to page number. true if the page was found false otherwise.



save
public void save(String fileName) throws IOException, COSVisitorException(Code)
This will save this document to the filesystem.
Parameters:
  fileName - The file to save as.
throws:
  IOException - If there is an error saving the document.
throws:
  COSVisitorException - If an error occurs while generating the data.



save
public void save(OutputStream output) throws IOException, COSVisitorException(Code)
This will save the document to an output stream.
Parameters:
  output - The stream to write to.
throws:
  IOException - If there is an error writing the document.
throws:
  COSVisitorException - If an error occurs while generating the data.



setDocumentInformation
public void setDocumentInformation(PDDocumentInformation info)(Code)
This will set the document information for this document.
Parameters:
  info - The updated document information.



setEncryptionDictionary
public void setEncryptionDictionary(PDEncryptionDictionary encDictionary) throws IOException(Code)
This will set the encryption dictionary for this document.
Parameters:
  encDictionary - The encryption dictionary(most likely a PDStandardEncryption object)
throws:
  IOException - If there is an error determining which security handler to use.



silentPrint
public void silentPrint() throws PrinterException(Code)
This will send the PDF to the default printer without prompting the user for any printer settings.
See Also:   PDDocument.print
throws:
  PrinterException - If there is an error while printing.



wasDecryptedWithOwnerPassword
public boolean wasDecryptedWithOwnerPassword()(Code)
This will tell if the document was decrypted with the master password. This entry is invalid if the PDF was not decrypted. true if the pdf was decrypted with the master password.



willEncryptWhenSaving
public boolean willEncryptWhenSaving()(Code)
Internal method do determine if the document will be encrypted when it is saved. True if encrypt has been called and the document has not been saved yet.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.