java.lang.AutoCloseable
PreparedDocument
public class Document extends NativeObject implements java.lang.AutoCloseable
open(com.pdftools.sys.Stream)
or the result of an operation, e.g. of PDF optimization (see pdftools.optimization.Optimizer.optimizeDocument
).Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the object.
|
Conformance |
getConformance() |
The claimed conformance of the document (Getter)
|
boolean |
getIsLinearized() |
Whether the document is linearized (Getter)
|
boolean |
getIsSigned() |
|
Metadata |
getMetadata() |
The metadata of the document.
|
int |
getPageCount() |
The number of pages in the document (Getter)
|
java.util.EnumSet<Permission> |
getPermissions() |
The access permissions applicable for this document (Getter)
|
SignatureFieldList |
getSignatureFields() |
|
XfaType |
getXfa() |
Whether the document is an XML Forms Architecture (XFA) or a PDF document (Getter)
|
static Document |
open(Stream stream) |
Open a PDF document.
|
static Document |
open(Stream stream,
java.lang.String password) |
Open a PDF document.
|
equals, hashCode
public static Document open(Stream stream) throws GenericException, LicenseException, CorruptException, PasswordException, UnsupportedFeatureException
stream
- The stream from which the PDF is read.LicenseException
- The license check has failed.PasswordException
- The document is encrypted and the password
is invalid.CorruptException
- The document is corrupt or not a PDF.UnsupportedFeatureException
- The document is an unencrypted wrapper document.GenericException
- A generic error occurred.java.lang.IllegalArgumentException
- if stream
is null
public static Document open(Stream stream, java.lang.String password) throws GenericException, LicenseException, CorruptException, PasswordException, UnsupportedFeatureException
stream
- The stream from which the PDF is read.password
- The password to open the PDF document.
If null
or empty, no password is used.LicenseException
- The license check has failed.PasswordException
- The document is encrypted and the password
is invalid.CorruptException
- The document is corrupt or not a PDF.UnsupportedFeatureException
- The document is an unencrypted wrapper document.GenericException
- A generic error occurred.java.lang.IllegalArgumentException
- if stream
is null
public Conformance getConformance()
This method only returns the claimed conformance level, the document is not validated.
This property can return null
if the document's conformance is unknown.
public int getPageCount()
0
.public java.util.EnumSet<Permission> getPermissions()
This property is null
, if the document is not encrypted.
Note that these permissions might be different from the "Document Restrictions Summary" displayed in Adobe Acrobat. This is because Acrobat's restrictions are also affected by other factors. For example, "Document Assembly" is generally only allowed in Acrobat Pro and not the Acrobat Reader.
public boolean getIsLinearized()
public boolean getIsSigned()
public SignatureFieldList getSignatureFields()
public XfaType getXfa()
UnsupportedFeatureException
).
An XFA form is included as a resource in a mere shell PDF.
The PDF pages' content is generated dynamically from the XFA data, which is a complex, non-standardized process.
For this reason, XFA is forbidden by the ISO Standards ISO 19'005-2 (PDF/A-2) and ISO 32'000-2 (PDF 2.0) and newer.
It is recommended to convert XFA documents to PDF using an Adobe product, e.g. by using the "Print to PDF" function of Adobe Acrobat Reader.public Metadata getMetadata()
public void close() throws PdfToolsException, java.io.IOException
close
in interface java.lang.AutoCloseable
PdfToolsException
- only explicitly stated in a superclassjava.io.IOException