|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectidainfront.pdfcreator4j.PdfCreatorApi
public class PdfCreatorApi
A simple API wrapping the exposed methods and properties in the PDFCreator COM API. An example of using the API:
PdfCreatorApi api = new PdfCreatorApi(); try { api.start(); boolean canPrint = api.isPrintable("c:\\tmp\\test.pdf"); //... } catch(PdfCreatorException e){ //... } finally { api.dispose(); }The call to
disposeCOMThread()
is important, and needs to be in a
finally-clause. This will dispose of threads and resources relating to the
COM bridge used.
Nested Class Summary | |
---|---|
static class |
PdfCreatorApi.EventHandler
Event handler for listening to COM-events generated by PdfCreator |
Field Summary | |
---|---|
static int |
STATUS_IN_PROGRESS
|
static int |
STATUS_READY
|
static int |
STATUS_WITH_ERRORS
|
Constructor Summary | |
---|---|
PdfCreatorApi()
|
Method Summary | |
---|---|
void |
clearCache()
Perform a clearcache call to the Pdf Creator Com-Interface. |
void |
close()
Tries to close the process for pdf creator by invoking the method cClose on the pdf creator COM-interface. |
void |
disposeCOMThread()
Dispose of any resources acquired for the COM bridge. |
String |
getDefaultPrinter()
Get the default printer in OS from the Pdf Creator COM-interface |
PdfCreatorError |
getError()
|
String |
getProperty(String property)
Gets a property from the pdf creator options. |
int |
getStatus()
Status state of PdfCreatorAPI. |
Variant |
invoke(String key,
Object object)
|
boolean |
isClosed()
This method checks whether the ActiveXComponent has been released. |
boolean |
isPrintable(String file)
Check whether a file can be printed by PdfCreator. |
boolean |
isRunning()
A call to the PDF Creator COM-Api to see if the program (process) is running. |
void |
printFile(String filename)
|
void |
setCoption(String property,
Object value)
Set a specific option parameter. |
void |
setCoptions(Map<String,Object> properties)
Set an map |
void |
setDefaultPrinter(String printer)
Setter for default printer. |
void |
setPrinterStop(boolean stop)
Flag that indicates whether printing should be enabled or not. |
protected void |
setStatus(int status)
Method that sets the status of our PdfCreator. |
void |
setVisible(boolean value)
Sets whether the application/tray icon should be visible when pdf creator is running |
void |
showLogFileDialog(boolean value)
Calls the Pdf Creator Com Interface whether the log fil dialog should be visible or not. |
boolean |
start()
Start PdfCreator with no additional options. |
boolean |
start(boolean forceIntialize)
This starts the Pdf Creator process through a COM call. |
boolean |
start(String options)
|
boolean |
start(String options,
boolean forceIntialize)
|
void |
writeToLogFile(String filePath)
Calls the PDF Creator COM-Api with a file path to save a log fil to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATUS_IN_PROGRESS
public static final int STATUS_WITH_ERRORS
public static final int STATUS_READY
Constructor Detail |
---|
public PdfCreatorApi()
Method Detail |
---|
public void disposeCOMThread()
public boolean isPrintable(String file) throws PdfCreatorException
file
- Filename to check
true
if the file is printable, false
otherwise.
PdfCreatorException
public boolean isRunning() throws PdfCreatorException
true
if the program (process) is running,
otherwise false
PdfCreatorException
- if COM call failedpublic void writeToLogFile(String filePath)
filePath
- The path to the file where the log should be saved.public void showLogFileDialog(boolean value) throws PdfCreatorException
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic int getStatus()
PdfCreatorApi.STATUS_IN_PROGRESS
if Pdf Creator hasn't sent any event,
PdfCreatorApi.STATUS_WITH_ERRORS
if the Pdf Creator has sent an eError event or
PdfCreatorApi.STATUS_READY
if the Pdf Creator has sent an eReady event.protected void setStatus(int status)
status
- PdfCreatorApi.STATUS_IN_PROGRESS
if Pdf Creator hasn't sent any event,
PdfCreatorApi.STATUS_WITH_ERRORS
if the Pdf Creator has sent an eError event or
PdfCreatorApi.STATUS_READY
if the Pdf Creator has sent an eReady event.public boolean start(boolean forceIntialize) throws PdfCreatorException
forceIntialize
- this is useful if a process for Pdf creator is already started,
true
will take over this process, otherwise a new process will be created.
true
if the startup of the Pdf Creator process was successful
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic boolean start(String options, boolean forceIntialize) throws PdfCreatorException
options
- forceIntialize
-
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic boolean start(String options) throws PdfCreatorException
options
-
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic boolean start() throws PdfCreatorException
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic void close() throws PdfCreatorException
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic void clearCache() throws PdfCreatorException
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic String getDefaultPrinter() throws PdfCreatorException
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic void setVisible(boolean value)
value
- true
if it should be visible.public void setDefaultPrinter(String printer) throws PdfCreatorException
printer
- the printer to use.
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic String getProperty(String property)
property
- The property to get it's value from.
public void setCoption(String property, Object value) throws PdfCreatorException
property
- the option keyvalue
- the value for the property key
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic void setCoptions(Map<String,Object> properties) throws PdfCreatorException
properties
- as a map
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic void setPrinterStop(boolean stop) throws PdfCreatorException
stop
- true
if printing should be disabled
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic PdfCreatorError getError()
public void printFile(String filename) throws PdfCreatorException
filename
- the path to the file. Note: this must be a absolute path or PDF Creator will
complain.
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic Variant invoke(String key, Object object) throws PdfCreatorException
key
- String representing the name of the method to call.object
- A parameter as an Object.
PdfCreatorException
- if the call to COM-interface was unsuccessfulpublic boolean isClosed()
true
true
if closed properly
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |