public class PDFOptimizer extends Object
PDFOptimizer
class provides methods to load and optimize a PDF document.Modifier and Type | Class and Description |
---|---|
static class |
PDFOptimizer.KeyInfoOptimizer
This is the Main-Class for the jPDFOptimizer.jar, it can generate server key
requests, validate a key, and display server information.
|
Constructor and Description |
---|
PDFOptimizer(InputStream inStream,
IPassword password)
Creates a PDFOptimizer object by loading a PDF document from an InputStream.
|
PDFOptimizer(PDFSource pdfSource,
IPassword password)
Creates a PDFOptimizer object by loading a PDF document from a
PDFSource object. |
PDFOptimizer(String fileName,
IPassword password)
Loads a PDF document from a file.
|
PDFOptimizer(URL url,
IPassword password)
Creates a PDFOptimizer object by loading a PDF document from a URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this PDFOptimizer object.
|
AuditResults |
audit()
Audits the PDFDocument and returns the audit results.
|
void |
close()
Close / release all resources held by this document.
|
DocumentInfo |
getDocumentInfo()
Returns a DocumentInfo object containing the information
section of a PDF document (author, title, etc.)
|
int |
getPageCount()
Returns the number of pages in this document.
|
AllPDFPermissions |
getPDFPermissions()
Returns the AllPDFPermissions object which encompasses this document's PasswordPermissions, DocMDPPermissions, and UsageRightsPermissions.
|
static String |
getVersion()
Returns version string for jPDFOptimizer.
|
static void |
loadLicense(InputStream licenseStream)
Method to load a license file from an inputstream.
|
static void |
loadLicense(String licenseFile)
Method to load a license file.
|
OptimizeResults |
optimize(OptSettings optInfo,
OutputStream outStream)
Optimizes and saves this document to an output stream.
|
OptimizeResults |
optimize(OptSettings optInfo,
OutputStream outStream,
File log)
Deprecated.
As of 2017R1 replaced by
optimize(OptSettings, OutputStream) . |
OptimizeResults |
optimize(OptSettings optInfo,
String outFile)
Optimize and save this document to a file.
|
OptimizeResults |
optimize(OptSettings optInfo,
String outFile,
File log)
Deprecated.
As of 2017R1 replaced by
optimize(OptSettings, String) . |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener so that it will stop being notified for progress.
|
static boolean |
setAppletKey(String key,
Applet applet)
Method to unlock the production version of the library when running in an applet.
|
static boolean |
setKey(String key)
Method to unlock the production version of the library.
|
boolean |
usePermissionsPassword(String ownerPassword)
Tells the PDFOptimizer object that the permissions password is known, so all
permissions are granted.
|
public PDFOptimizer(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.PDFException
public PDFOptimizer(InputStream inStream, IPassword password) throws PDFException
inStream
- InputStream to read the PDF document.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.PDFException
public PDFOptimizer(URL url, IPassword password) throws PDFException
url
- Location of the PDF document.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.PDFException
public PDFOptimizer(PDFSource pdfSource, IPassword password) throws PDFException
PDFSource
object.pdfSource
- The source for the PDF document.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.PDFException
public void close()
public static boolean setKey(String key)
key
- Production key.public static void loadLicense(InputStream licenseStream) throws com.qoppa.pdf.LicenseException
licenseStream
- The input stream for the license file contents.com.qoppa.pdf.LicenseException
- If there are any problems with the license filepublic static void loadLicense(String licenseFile) throws com.qoppa.pdf.LicenseException, IOException
licenseFile
- The full path to the license file.com.qoppa.pdf.LicenseException
- If there are any problems with the license fileIOException
public static boolean setAppletKey(String key, Applet applet)
key
- Production key.public DocumentInfo getDocumentInfo()
public int getPageCount() throws PDFException
PDFException
public final AllPDFPermissions getPDFPermissions()
public static String getVersion()
public OptimizeResults optimize(OptSettings optInfo, OutputStream outStream) throws PDFException, IOException
optInfo
- The optimization options.outStream
- The output stream to write the document to.PDFException
IOException
public OptimizeResults optimize(OptSettings optInfo, OutputStream outStream, File log) throws PDFException, IOException
optimize(OptSettings, OutputStream)
.optInfo
- The optimization options.outStream
- The output stream to write the document to.log
- The file to write the optimizer log.PDFException
IOException
public OptimizeResults optimize(OptSettings optInfo, String outFile) throws PDFException, IOException
optInfo
- The optimization options.outFile
- The output file to write the document to.PDFException
IOException
public OptimizeResults optimize(OptSettings optInfo, String outFile, File log) throws PDFException, IOException
optimize(OptSettings, String)
.optInfo
- The optimization options.outFile
- The output file to write the document to.log
- The file to write the optimizer log.PDFException
IOException
public AuditResults audit() throws IOException
IOException
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The object to receive PropertChangeEvents.public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- the listener to remove.public boolean usePermissionsPassword(String ownerPassword) throws PDFException
ownerPassword
- The permissions passwordPDFException