Modifier and Type | Class and Description |
---|---|
static class |
PDFPrint.KeyInfoPrint
This is the Main-Class for the jPDFPrint.jar that can generate server key
requests, validate a key, and display server information.
|
NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
PDFPrint(InputStream inStream,
IPassword password)
Loads a PDF document from an InputStream.
|
PDFPrint(String fileName,
IPassword password)
Loads a PDF document from a file.
|
PDFPrint(URL url,
IPassword password)
Loads a PDF document from a URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addPrintListener(PrintListener printListener)
Adds a
PrintListener to the PDFDocument |
void |
close()
Close / release all resources held by this document.
|
SimpleDoc |
createSimpleDoc(DocAttributeSet attributes)
Creates and returns a SimpleDoc, with the specified doc attribute set,
which can be used in many common printing requests.
|
Pageable |
getPageable(PrinterJob pJob)
Returns an object that implements Pageable for this PDF document.
|
int |
getPageCount()
Returns the number of pages in this document.
|
PageFormat |
getPageFormat(int pageIndex)
Returns a PageFormat object for the given page.
|
PrintSettings |
getPrintSettings()
Returns the PrintSettings that will be used when printing the document.
|
static String |
getVersion()
Returns version string for jPDFPrint.
|
IWatermark |
getWatermark()
Returns the watermark for the PDFPrint document.
|
boolean |
isPrintAllowed()
Returns whether this document has permissions to print.
|
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.
|
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.
|
static void |
print(String fileName,
PrintSettings printSettings,
IPassword password)
Convenience method to print a PDF document from a file.
|
void |
print(String printerName,
PrintSettings printSettings,
PrintRequestAttributeSet printAttrSet)
Prints this PDF document to the specified printer, by name and passes the attribute set to the printer job.
|
static void |
print(String fileName,
String printerName,
PrintSettings printSettings,
IPassword password)
Convenience method to print a PDF document from a file to a named printer.
|
void |
printAsImage(String printerName,
PrintSettings printSettings,
PrintRequestAttributeSet printAttrSet)
Prints this document by first converting each page to an image and then sending the image to the printer.
|
void |
printToDefaultPrinter(PrintSettings printSettings)
Prints the PDF document to the default printer.
|
void |
removePrintListener(PrintListener printListener)
Removes a
PrintListener from the PDFDocument |
static boolean |
setAppletKey(String key,
Applet applet)
Method to unlock the production version of the library.
|
static boolean |
setKey(String key)
Method to unlock the production version of the library.
|
void |
setPrintSettings(PrintSettings printSettings)
Set the PrintSettings used when printing this document while using the class as a Printable
(rather than calling one of the print methods).
|
void |
setWatermark(IWatermark watermark)
Sets the watermark on the PDFPrint document.
|
boolean |
usePermissionsPassword(String ownerPassword)
Tells the PDFPrint object that the permissions password is known, so all
permissions are granted.
|
public PDFPrint(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 PDFPrint(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 PDFPrint(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 static void print(String fileName, PrintSettings printSettings, IPassword password) throws PrinterException, PDFException
fileName
- Name of the PDF file.printSettings
- Print job settings. Use this object to tell
the library how to print the document. The library uses default
settings when null is used.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.PrinterException
PDFException
public static void print(String fileName, String printerName, PrintSettings printSettings, IPassword password) throws PrinterException, PDFException
fileName
- Name of the PDF file.printerName
- Name of the printer to print to. If null, prints to
the default printer.printSettings
- Print job settings. Use this object to tell
the library how to print the document. The library uses default
settings when null is used.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.PrinterException
PDFException
public void print(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.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.PDFPermissionException
public void printToDefaultPrinter(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.PrinterException
- This exception is thrown if the printer is not
found or if there is an error while printing.PDFPermissionException
public SimpleDoc createSimpleDoc(DocAttributeSet attributes)
Example:
PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob printJob = printService.createPrintJob(); DocumentName docName = new DocumentName("Doc Name", Locale.getDefault()); HashDocAttributeSet attributes = new HashDocAttributeSet(docName); try { PDFPrint pdfPrint = new PDFPrint("sampleFile.pdf", null); printJob.print(pdfPrint.createSimpleDoc(attributes), null); } catch (PDFException e) { e.printStackTrace(); } catch (PrintException e) { e.printStackTrace(); }
attributes
- a DocAttributeSet
, which can be null
public static boolean setKey(String key)
key
- Production key.public static void loadLicense(InputStream licenseStream) throws LicenseException
licenseStream
- The input stream for the license file contents.LicenseException
- If there are any problems with the license filepublic static void loadLicense(String licenseFile) throws LicenseException, IOException
licenseFile
- The full path to the license file.LicenseException
- If there are any problems with the license fileIOException
public static boolean setAppletKey(String key, Applet applet)
key
- Production key.public static String getVersion()
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
print
in interface Printable
PrinterException
public PrintSettings getPrintSettings()
public Pageable getPageable(PrinterJob pJob)
pJob
- PrinterJob object where the Pageable will be used.public void setPrintSettings(PrintSettings printSettings)
printSettings
- PrintSettings to use when printing.public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException
IndexOutOfBoundsException
public int getPageCount()
public boolean isPrintAllowed()
public void close()
public boolean usePermissionsPassword(String ownerPassword) throws PDFException
ownerPassword
- The permissions passwordPDFException
public void setWatermark(IWatermark watermark)
IWatermark.TYPE_PRINT
when printing the document.watermark
- the IWatermark
object to use when printing the
PDFPrint documentpublic IWatermark getWatermark()
IWatermark
objectsetWatermark(com.qoppa.pdf.IWatermark)
public void addPrintListener(PrintListener printListener)
PrintListener
to the PDFDocumentprintListener
- - the PrintListener
to be addedpublic void removePrintListener(PrintListener printListener)
PrintListener
from the PDFDocumentprintListener
- - the PrintListener
to be removedpublic void printAsImage(String printerName, PrintSettings printSettings, PrintRequestAttributeSet printAttrSet) throws PDFPermissionException, PrinterException
printerName
- The name of the printer to print to. If this parameter
is set to null, the method will print to the default printer.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.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.PDFPermissionException
- This exception is thrown if the PDF does not allow for printing.PrinterException
- This exception is thrown if the printer is not
found or if there is an error while printing.PrinterException