|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Objectcom.princexml.Prince
public class Prince
The main Prince class.
| Constructor Summary | |
|---|---|
Prince(String exePath)
Constructor for Prince. |
|
Prince(String exePath,
PrinceEvents events)
Constructor for Prince. |
|
| Method Summary | |
|---|---|
void |
addStyleSheet(String cssPath)
Add a CSS style sheet that will be applied to each document. |
void |
clearStyleSheets()
Clear all of the CSS style sheets. |
boolean |
convert(InputStream xmlInput,
OutputStream pdfOutput)
Convert an XML or HTML file to a PDF file. |
boolean |
convert(String xmlPath)
Convert an XML or HTML file to a PDF file. |
boolean |
convert(String xmlPath,
String pdfPath)
Convert an XML or HTML file to a PDF file. |
void |
setBaseURL(String baseurl)
Specify the base URL of the input document. |
void |
setCompress(boolean compress)
Specify whether compression should be applied to the output PDF file. |
void |
setEmbedFonts(boolean embedFonts)
Specify whether fonts should be embedded in the output PDF file. |
void |
setEncrypt(boolean encrypt)
Specify whether encryption should be applied to the output PDF file. |
void |
setEncryptInfo(int keyBits,
String userPassword,
String ownerPassword,
boolean disallowPrint,
boolean disallowModify,
boolean disallowCopy,
boolean disallowAnnotate)
Set the parameters used for PDF encryption. |
void |
setHTML(boolean html)
Specify whether documents should be parsed as HTML or XML/XHTML. |
void |
setLog(String logfile)
Specify a file that Prince should use to log error/warning messages. |
void |
setXInclude(boolean xinclude)
Specify whether XML Inclusions (XInclude) processing should be applied to input documents. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Prince(String exePath)
exePath - The path of the Prince executable. (For example, this
may be C:\Program Files\Prince\engine\bin\prince.exe
on Windows or /usr/bin/prince on Linux).
public Prince(String exePath,
PrinceEvents events)
exePath - The path of the Prince executable. (For example, this
may be C:\Program Files\Prince\engine\bin\prince.exe
on Windows or /usr/bin/prince on Linux).events - An instance of the PrinceEvents interface that will
receive error/warning messages returned from Prince.| Method Detail |
|---|
public void addStyleSheet(String cssPath)
cssPath - The filename of the CSS style sheet.public void clearStyleSheets()
public void setHTML(boolean html)
This is also necessary if a HTML document is passed to Prince from an InputStream, as this has no filename and hence Prince will not check the extension and will always treat it as XML/XHTML unless this method has been called.
html - True if all documents should be treated as HTML, false
otherwise.public void setLog(String logfile)
logfile - The filename that Prince should use to log error/warning
messages, or null to disable logging.public void setBaseURL(String baseurl)
baseurl - The base URL or path of the input document.public void setXInclude(boolean xinclude)
xinclude - False to disable XInclude processing.public void setEmbedFonts(boolean embedFonts)
embedFonts - False to disable PDF font embedding.public void setCompress(boolean compress)
compress - False to disabled PDF compression.public void setEncrypt(boolean encrypt)
encrypt - True to enable PDF encryption.
public void setEncryptInfo(int keyBits,
String userPassword,
String ownerPassword,
boolean disallowPrint,
boolean disallowModify,
boolean disallowCopy,
boolean disallowAnnotate)
setEncrypt(true).
keyBits - The size of the encryption key in bits (must be 40 or
128).userPassword - The user password for the encrypted PDF file.ownerPassword - The owner password for the encrypted PDF file.disallowPrint - True to disallow printing of the encrypted PDF
file.disallowModify - True to disallow modification of the encrypted
PDF file.disallowCopy - True to disallow copying from the encrypted PDF
file.disallowAnnotate - True to disallow annotation of the encrypted
PDF file.
IllegalArgumentException - if keyBits is not 40 or 128.
public boolean convert(String xmlPath)
throws IOException
xmlPath - The filename of the input XML or HTML document.
IOException
public boolean convert(String xmlPath,
String pdfPath)
throws IOException
xmlPath - The filename of the input XML or HTML document.pdfPath - The filename of the output PDF file.
IOException
public boolean convert(InputStream xmlInput,
OutputStream pdfOutput)
throws IOException
Note that it may be helpful to specify a base URL or path for the input document using the setBaseURL() method. This allows relative URLs and paths in the document (eg. for images) to be resolved correctly.
Note that no error/warning messages will be returned via the
PrinceEvents interface when calling this method. This is due to a
limitation of Prince that will be fixed in a future release. In the
meantime, we recommend the use of the setLog() method to
specify a log file that can be used to view error/warning messages from
Prince.
xmlInput - The InputStream from which Prince will read the XML or
HTML document.pdfOutput - The OutputStream to which Prince will write the PDF
output.
IOException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||