public class PDFreactor extends Object
PDFreactor
converts HTML and XML documents into PDF and provides
a large number of settings for the conversion process.
This sample demonstrates the use of PDFreactor:
PDFreactor
pdfReactor = new PDFreactor
();
FileOutputStream
outputStream = new FileOutputStream
("realobjects.pdf");
pdfReactor.setAddBookmarks(true);
pdfReactor.setAddLinks(true);
byte[] pdf = pdfReactor.renderDocumentFromURL("http://www.realobjects.com/");
outputStream.write(pdf);
outputStream.close();
Please note: A new instance of PDFreactor
should be created for every conversion.
Important: On a system without a graphical environment you have to enable the headless mode by setting the appropriate system property. Please see the manual for details.
For more information please have a look at the PDFreactor manual.
Modifier and Type | Field and Description |
---|---|
static int |
CLEANUP_CYBERNEKO
Indicates that the CyberNeko HTML parser will be used to perform a
cleanup when loading a non-well-formed document.
|
static int |
CLEANUP_JTIDY
Indicates that JTidy will be used to perform a cleanup when loading a
non-well-formed document.
|
static int |
CLEANUP_NONE
Indicates that no cleanup will be performed when loading a document.
|
static int |
CLEANUP_TAGSOUP
Indicates that tagsoup will be used to perform a
cleanup when loading a non-well-formed document.
|
static int |
COLOR_SPACE_CMYK
The default color space.
|
static int |
COLOR_SPACE_RGB
The color space RGB
|
static int |
CONFORMANCE_PDF
PDF with no additional restrictions (default)
|
static int |
CONFORMANCE_PDFA
Deprecated.
As of PDFreactor 7.0, replaced by
PDFreactor.CONFORMANCE_PDFA1A |
static int |
CONFORMANCE_PDFA1A
PDF/A-1a (ISO 19005-1 Level A)
|
static int |
CONFORMANCE_PDFA3A
PDF/A-3a (ISO 19005-3 Level A)
|
static int |
DOCTYPE_AUTODETECT
Indicates that the document type will be detected automatically.
|
static int |
DOCTYPE_HTML5
Indicates that the document type will be set to HTML5.
|
static int |
DOCTYPE_XHTML
Indicates that the document type will be set to XHTML.
|
static int |
DOCTYPE_XML
Indicates that the document type will be set to generic XML.
|
static int |
ENCRYPTION_128
Indicates that the document will be encrypted using RC4 128 bit encryption.
|
static int |
ENCRYPTION_40
Indicates that the document will be encrypted using RC4 40 bit encryption.
|
static int |
ENCRYPTION_NONE
Indicates that the document will not be encrypted.
|
static int |
EXCEEDING_CONTENT_AGAINST_NONE
Do not log exceeding content
|
static int |
EXCEEDING_CONTENT_AGAINST_PAGE_BORDERS
Log content exceeding the edges of its page
|
static int |
EXCEEDING_CONTENT_AGAINST_PAGE_CONTENT
Log content exceeding its page content area (overlaps the page margin)
|
static int |
EXCEEDING_CONTENT_AGAINST_PARENT
Log content exceeding its container
|
static int |
EXCEEDING_CONTENT_ANALYZE_CONTENT
Log exceeding content
|
static int |
EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_BOXES
Log exceeding content and all boxes
|
static int |
EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_STATIC_BOXES
Log exceeding content and boxes without absolute positioning
|
static int |
EXCEEDING_CONTENT_ANALYZE_NONE
Do not log exceeding content
|
static int |
HTTPS_MODE_LENIENT
Indicates lenient HTTPS behavior.
|
static int |
HTTPS_MODE_STRICT
Indicates strict HTTPS behavior.
|
static int |
JAVASCRIPT_MODE_DISABLED
Indicates that JavaScript is disabled.
|
static int |
JAVASCRIPT_MODE_ENABLED
Indicates that JavaScript is enabled.
|
static int |
JAVASCRIPT_MODE_ENABLED_NO_LAYOUT
Indicates that JavaScript is enabled, without access to layout data.
|
static int |
JAVASCRIPT_MODE_ENABLED_REAL_TIME
Indicates that JavaScript is enabled,
without converter-specific optimizations to timeouts and intervals.
|
static int |
JAVASCRIPT_MODE_ENABLED_TIME_LAPSE
Indicates that JavaScript is enabled,
with time stamps increasing more quickly.
|
static String |
KEYSTORE_TYPE_JKS
Keystore type "jks"
|
static String |
KEYSTORE_TYPE_PKCS12
Keystore type "pkcs12"
|
static int |
LOG_LEVEL_DEBUG
Indicates that debug, info, warn and fatal log events will be logged.
|
static int |
LOG_LEVEL_FATAL
Indicates that only fatal log events will be logged.
|
static int |
LOG_LEVEL_INFO
Indicates that info, warn and fatal log events will be logged.
|
static int |
LOG_LEVEL_NONE
Indicates that no log events will be logged.
|
static int |
LOG_LEVEL_PERFORMANCE
Indicates that all log events will be logged.
|
static int |
LOG_LEVEL_WARN
Indicates that warn and fatal log events will be logged.
|
static int |
MERGE_MODE_APPEND
Default merge mode: Append converted document to existing PDF
|
static int |
MERGE_MODE_OVERLAY
Alternate merge mode (overlay): Adding converted document above the existing PDF
|
static int |
MERGE_MODE_OVERLAY_BELOW
Alternate merge mode (overlay): Adding converted document below the existing PDF
|
static int |
MERGE_MODE_PREPEND
Alternate merge mode: Prepend converted document to existing PDF
|
static int |
OUTPUT_FORMAT_BMP
BMP output format
|
static int |
OUTPUT_FORMAT_GIF
GIF output format
|
static int |
OUTPUT_FORMAT_JPEG
JPEG output format
|
static int |
OUTPUT_FORMAT_PDF
PDF output format
|
static int |
OUTPUT_FORMAT_PNG
PNG output format (using Java Image I/O)
|
static int |
OUTPUT_FORMAT_PNG_AI
PNG output format (using Apache Imaging)
|
static int |
OUTPUT_FORMAT_PNG_TRANSPARENT
Transparent PNG output format (using Java Image I/O)
|
static int |
OUTPUT_FORMAT_PNG_TRANSPARENT_AI
Transparent PNG output format (using Apache Imaging)
|
static int |
OUTPUT_FORMAT_TIFF_CCITT_1D
Monochrome CCITT 1D compressed TIFF output format
|
static int |
OUTPUT_FORMAT_TIFF_CCITT_GROUP_3
Monochrome CCITT Group 3 compressed TIFF output format
|
static int |
OUTPUT_FORMAT_TIFF_CCITT_GROUP_4
Monochrome CCITT Group 4 compressed TIFF output format
|
static int |
OUTPUT_FORMAT_TIFF_LZW
LZW compressed TIFF output format
|
static int |
OUTPUT_FORMAT_TIFF_PACKBITS
PackBits compressed TIFF output format
|
static int |
OUTPUT_FORMAT_TIFF_UNCOMPRESSED
Uncompressed TIFF output format
|
static int |
OVERLAY_REPEAT_ALL_PAGES
All pages of the shorter document are repeated, to overlay all pages of the longer document
|
static int |
OVERLAY_REPEAT_LAST_PAGE
Last page of the shorter document is repeated, to overlay all pages of the longer document
|
static int |
OVERLAY_REPEAT_NONE
No pages of the shorter document are repeated, leaving some pages of the longer document without overlay
|
static String |
PAGE_ORDER_BOOKLET
Page order mode to arrange all pages in booklet order
|
static String |
PAGE_ORDER_BOOKLET_RTL
Page order mode to arrange all pages in right-to-left booklet order
|
static String |
PAGE_ORDER_EVEN
Page order mode to keep even pages only
|
static String |
PAGE_ORDER_ODD
Page order mode to keep odd pages only
|
static String |
PAGE_ORDER_REVERSE
Page order mode to reverse the page order
|
static int |
PAGES_PER_SHEET_DIRECTION_DOWN_LEFT
Arranges the pages on a sheet from top to bottom and right to left
|
static int |
PAGES_PER_SHEET_DIRECTION_DOWN_RIGHT
Arranges the pages on a sheet from top to bottom and left to right
|
static int |
PAGES_PER_SHEET_DIRECTION_LEFT_DOWN
Arranges the pages on a sheet from right to left and top to bottom
|
static int |
PAGES_PER_SHEET_DIRECTION_LEFT_UP
Arranges the pages on a sheet from right to left and bottom to top
|
static int |
PAGES_PER_SHEET_DIRECTION_RIGHT_DOWN
Arranges the pages on a sheet from left to right and top to bottom
|
static int |
PAGES_PER_SHEET_DIRECTION_RIGHT_UP
Arranges the pages on a sheet from left to right and bottom to top
|
static int |
PAGES_PER_SHEET_DIRECTION_UP_LEFT
Arranges the pages on a sheet from bottom to top and right to left
|
static int |
PAGES_PER_SHEET_DIRECTION_UP_RIGHT
Arranges the pages on a sheet from bottom to top and left to right
|
static int |
PROCESSING_PREFERENCES_SAVE_MEMORY_IMAGES
Processing preferences flag for the memory saving mode for images
|
static int |
SIGNING_MODE_SELF_SIGNED
Signing mode for self-signed certificates
|
static int |
SIGNING_MODE_VERISIGN_SIGNED
Signing mode for VeriSign certificates.
|
static int |
SIGNING_MODE_WINCER_SIGNED
Signing mode for Windows certificates.
|
static int |
VIEWER_PREFERENCES_CENTER_WINDOW
Position the document's window in the center of the screen.
|
static int |
VIEWER_PREFERENCES_DIRECTION_L2R
Position pages in ascending order from left to right.
|
static int |
VIEWER_PREFERENCES_DIRECTION_R2L
Position pages in ascending order from right to left.
|
static int |
VIEWER_PREFERENCES_DISPLAY_DOC_TITLE
Display the document's title in the top bar.
|
static int |
VIEWER_PREFERENCES_DUPLEX_FLIP_LONG_EDGE
Print dialog default setting: duplex (long edge)
|
static int |
VIEWER_PREFERENCES_DUPLEX_FLIP_SHORT_EDGE
Print dialog default setting: duplex (short edge)
|
static int |
VIEWER_PREFERENCES_DUPLEX_SIMPLEX
Print dialog default setting: simplex
|
static int |
VIEWER_PREFERENCES_FIT_WINDOW
Resize the document's window to fit the size of the first displayed page.
|
static int |
VIEWER_PREFERENCES_HIDE_MENUBAR
Hide the viewer application's menu bar when the document is active.
|
static int |
VIEWER_PREFERENCES_HIDE_TOOLBAR
Hide the viewer application's tool bars when the document is active.
|
static int |
VIEWER_PREFERENCES_HIDE_WINDOW_UI
Hide user interface elements in the document's window.
|
static int |
VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_NONE
Show document outline panel on exiting full-screen mode.
|
static int |
VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OC
Show attachments panel on exiting full-screen mode.
|
static int |
VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OUTLINES
Show thumbnail images panel on exiting full-screen mode.
|
static int |
VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_THUMBS
Show optional content group panel on exiting full-screen mode.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_ONE_COLUMN
Display the pages in one column.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_SINGLE_PAGE
Display one page at a time.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_LEFT
Display the pages in two columns, with odd numbered pages on the left.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_RIGHT
Display the pages in two columns, with odd numbered pages on the right.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_LEFT
Display two pages at a time, with odd numbered pages on the left.
|
static int |
VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_RIGHT
Display two pages at a time, with odd numbered pages on the right.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
Switch to fullscreen mode on startup.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_USE_ATTACHMENTS
Show attachments panel on startup.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_USE_NONE
Show no panel on startup.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_USE_OC
Show optional content group panel on startup.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_USE_OUTLINES
Show document outline panel on startup.
|
static int |
VIEWER_PREFERENCES_PAGE_MODE_USE_THUMBS
Show thumbnail images panel on startup.
|
static int |
VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_FALSE
Print dialog default setting: do not pick tray by PDF size
|
static int |
VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_TRUE
Print dialog default setting: pick tray by PDF size
|
static int |
VIEWER_PREFERENCES_PRINTSCALING_APPDEFAULT
Print dialog default setting: set scaling to application default value.
|
static int |
VIEWER_PREFERENCES_PRINTSCALING_NONE
Print dialog default setting: disabled scaling
|
Constructor and Description |
---|
PDFreactor()
Creates an instance of
PDFreactor . |
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(byte[] data,
String url,
String name,
String description)
Adds a file attachment to PDF document.
|
void |
addCustomDocumentProperty(String name,
String value)
Adds a custom property to the PDF document.
|
void |
addFont(String source,
String family,
boolean bold,
boolean italic)
Loads a font from a URL which can be used via the CSS property
font-family . |
void |
addFontAlias(String source,
String family,
boolean bold,
boolean italic)
Registers an alias font family for an existing font.
|
void |
addFontDirectory(String fontDirectory)
Registers an additional font directory to load fonts from.
|
void |
addIntegrationStyleSheet(InputSource inputSource)
Adds a integration style sheet to the document.
|
void |
addIntegrationStyleSheet(String content,
String media,
String title,
String uri)
Adds an integration style sheet to the document.
|
void |
addProgressEventListener(ProgressEventListener listener)
Adds a
ProgressEventListener . |
void |
addUserScript(String content,
String uri,
boolean beforeDocumentScripts)
Adds an user script to the document.
|
void |
addUserStyleSheet(InputSource inputSource)
Adds a user style sheet to the document.
|
void |
addUserStyleSheet(String content,
String media,
String title,
String uri)
Adds a user style sheet to the document.
|
void |
addXSLTStyleSheet(String content,
String uri)
Adds an XSLT style sheet to the document.
|
void |
enableDebugMode()
Enables debug mode, which adds additional information to the output.
|
String |
getError()
Returns the error messages generated during rendering.
|
ExceedingContent[] |
getExceedingContents()
Provides information about content exceeding its page or parent.
|
String |
getLog()
Returns the log messages generated during rendering based on the log
level.
|
Logger |
getLogger()
Returns the
Logger used by this PDFreactor . |
int |
getNumberOfPages(boolean pdf)
Returns the number of pages of the document after conversion.
|
void |
removeAllIntegrationStyleSheets()
Removes all integration style sheets.
|
void |
removeAllUserScripts()
Removes all user scripts.
|
void |
removeAllUserStyleSheets()
Removes all user style sheets.
|
void |
removeAllXSLTStyleSheets()
Removes all XSLT style sheets.
|
void |
removeProgressEventListener(ProgressEventListener listener)
Removes a
ProgressEventListener . |
void |
renderDocument(InputSource inputSource,
OutputStream outputStream)
Generates a PDF document from an
InputSource . |
byte[] |
renderDocumentFromByteArray(byte[] array)
Generates a PDF document or an image from an HTML or XML document inside a byte-array.
|
byte[][] |
renderDocumentFromByteArrayAsArray(byte[] array)
Generates an array of byte-arrays each containing an image representing
one page of the document from an HTML or XML document inside a byte-array.
|
byte[] |
renderDocumentFromContent(String content)
Generates a PDF document or an image from an HTML or XML document inside a String.
|
byte[][] |
renderDocumentFromContentAsArray(String content)
Generates an array of byte-arrays each containing an image representing
one page of the document from an HTML or XML document inside a String.
|
byte[] |
renderDocumentFromURL(String url)
Generates a PDF document or an image from an HTML or XML document at a URL.
|
byte[][] |
renderDocumentFromURLAsArray(String url)
Generates an array of byte-arrays each containing an image representing
one page of the document from an HTML or XML document at a URL.
|
void |
setAddAttachments(boolean value)
Enables or disables attachments specified in style sheets.
|
void |
setAddBookmarks(boolean value)
Enables or disables bookmarks in the PDF document.
|
void |
setAddComments(boolean value)
Enables or disables comments in the PDF document.
|
void |
setAddLinks(boolean value)
Enables or disables links in the PDF document.
|
void |
setAddOverprint(boolean value)
Enables or disables overprinting.
|
void |
setAddPreviewImages(boolean value)
Enables or disables embedding of image previews per page in the PDF
document.
|
void |
setAddTags(boolean value)
Enables or disables tagging of the PDF document.
|
void |
setAllowAnnotations(boolean value)
Enables or disables the 'annotations' restriction in the PDF
document.
|
void |
setAllowAssembly(boolean value)
Enables or disables the 'assembly' restriction in the PDF
document.
|
void |
setAllowCopy(boolean value)
Enables or disables the 'copy' restriction in the PDF document.
|
void |
setAllowDegradedPrinting(boolean value)
Enables or disables the 'degraded printing' restriction in the PDF
document.
|
void |
setAllowFillIn(boolean value)
Enables or disables the 'fill in' restriction in the PDF document.
|
void |
setAllowModifyContents(boolean value)
Enables or disables the 'modify contents' restriction in the PDF
document.
|
void |
setAllowPrinting(boolean value)
Enables or disables the 'printing' restriction in the PDF
document.
|
void |
setAllowScreenReaders(boolean value)
Enables or disables the 'screen readers' restriction in the PDF
document.
|
void |
setAppendLog(boolean value)
Specifies whether or not the log data should be added to the
PDF document.
|
void |
setAuthenticationCredentials(String username,
String password)
Enables access to resources that are secured via Basic or Digest authentication.
|
void |
setAuthor(String value)
Sets the value of the author field of the PDF document.
|
void |
setBaseURL(String value)
Sets the base
URL of the XML document. |
void |
setBookletMode(String sheetSize,
String sheetMargin,
boolean rtl)
Convenience method to set pages-per-sheet properties and page order
in one step to create a booklet.
|
void |
setCacheFonts(boolean value)
Enables or disables caching of font information.
|
void |
setCleanupTool(int value)
Sets the cleanup tool to use for documents with unparsable content.
|
void |
setConformance(int conformance)
Sets the conformance of the PDF.
|
void |
setContinuousOutput(int width,
int height)
Enables the conversion of the input document into one image.
|
void |
setCookie(String key,
String value)
Adds a cookie to all outgoing HTTP connections.
|
void |
setCreator(String value)
Sets the value of creator field of the PDF document.
|
void |
setDefaultColorSpace(int defaultColorSpace)
Sets whether to convert color key words to CMYK instead of RGB.
|
void |
setDisableFontEmbedding(boolean disableFontEmbedding)
Sets whether fonts will not be embedded into the resulting PDF.
|
void |
setDisableFontRegistration(boolean value)
Enables or disables the font registration.
|
void |
setDisableSystemFonts(boolean value)
Enables or disables the use of system fonts.
|
void |
setDocumentDefaultLanguage(String languageCode)
Sets the language used for documents having no explicit language attribute set.
|
void |
setDocumentType(int value)
Sets the document type.
|
void |
setEncoding(String value)
Sets the encoding of the document.
|
void |
setEncryption(int value)
Sets the encryption.
|
void |
setFontCachePath(String location)
Sets the path of the font cache.
|
void |
setFontDirectory(String location)
Deprecated.
As of PDFreactor 6.0, replaced by
PDFreactor.addFontDirectory(String) |
void |
setFontFallback(String[] fontFallback)
Sets a list of fallback font families used for character substitution.
|
void |
setFullCompression(boolean value)
Enables or disables full compression of the PDF document.
|
void |
setHTTPSMode(int httpsMode)
Sets the HTTPS mode.
|
void |
setJavaScriptMode(int javaScriptMode)
Sets the JavaScript Mode.
|
void |
setKeywords(String value)
Sets the value of the keywords field of the PDF document.
|
void |
setLicenseKey(String content)
Sets the license key using a
String . |
void |
setLogExceedingContent(int logExceedingContentAnalyze,
int logExceedingContentAgainst)
Whether to log content exceeding the page.
|
void |
setLogger(Logger object)
Sets a
Logger to receive log messages. |
void |
setLogLevel(int value)
Sets the log level.
|
void |
setMergeBeforePDF(boolean value)
Deprecated.
As of PDFreactor 5.0, replaced by
PDFreactor.setMergeMode(int) |
void |
setMergeByteArray(byte[] array)
This method sets a byte array containing an external PDF document
which will be merged with the PDF document generated by the XML source.
|
void |
setMergeByteArrays(byte[][] arrays)
This method sets an array of byte arrays that contain multiple external PDFs
which will be merged with the PDF document generated by the XML source.
|
void |
setMergeMode(int mode)
Sets the merge mode.
|
void |
setMergeURL(String url)
This method sets a URL of an external PDF document which will be
merged with the PDF document generated by the XML source.
|
void |
setMergeURLs(String[] urls)
This method sets an array of URLs of external PDF documents which will be
merged with the PDF document generated by the XML source.
|
void |
setOutputFormat(int format,
int outputWidth,
int outputHeight)
Sets the output format.
|
void |
setOutputIntentFromByteArray(String identifier,
byte[] profileData)
Sets the output intent including the identifier and the ICC profile to be embedded into the PDF.
|
void |
setOutputIntentFromURL(String identifier,
String profileUrl)
Sets the output intent including the identifier and the ICC profile to be embedded into the PDF.
|
void |
setOverlayRepeat(int overlayRepeat)
If one of the documents of an overlay process is shorter than the other, this method
allows repeating either its last page or all of its pages in order to overlay all pages of
the longer document.
|
void |
setOwnerPassword(String value)
Sets the owner password of the PDF document.
|
void |
setPageOrder(String order)
Sets the page order of the direct result of the conversion.
|
void |
setPagesPerSheetProperties(int cols,
int rows,
String sheetSize,
String sheetMargin,
String spacing,
int direction)
Sets the properties of a sheet on which multiple pages are being arranged.
|
void |
setPixelsPerInch(int ppi)
Sets the pixels per inch.
|
void |
setPixelsPerInchShrinkToFit(boolean pixelsPerInchShrinkToFit)
Whether the pixels per inch should be adapted automatically to avoid content exceeding pages.
|
void |
setPostTransformationDocumentType(int value)
Sets the document type after the XSL-Transformations have been applied.
|
void |
setPrintDialogPrompt(boolean value)
Enables or disables a print dialog to be shown upon opening
the generated PDF document by a PDF viewer.
|
void |
setProcessingPreferences(int processingPreferences)
Preferences that influence the conversion process without changing
the output
|
void |
setRawCookie(String key,
String value)
Adds a cookie to all outgoing HTTP connections.
|
void |
setRequestHeader(String key,
String value)
Adds a request header to all outgoing HTTP connections.
|
void |
setSignPDF(String keystoreURL,
String keyAlias,
String keystorePassword,
String keystoreType,
int signingMode)
Sets a digital certificate to sign the newly created PDF.
|
void |
setSubject(String value)
Sets the value of the subject field of the PDF document.
|
void |
setThrowLicenseExceptions(boolean throwLicenseExceptions)
Whether an exception should be thrown when no legal full license key is set.
|
void |
setTitle(String value)
Sets the value of the title field of the PDF document.
|
void |
setUserPassword(String value)
Sets the user password of the PDF document.
|
void |
setViewerPreferences(int viewerPreferences)
Sets the page layout and page mode preferences of the PDF.
|
void |
setXSLTMode(boolean value)
Enables or disables XSLT transformations.
|
public static final int CLEANUP_NONE
public static final int CLEANUP_JTIDY
public static final int CLEANUP_CYBERNEKO
public static final int CLEANUP_TAGSOUP
public static final int DOCTYPE_AUTODETECT
PDFreactor.DOCTYPE_HTML5
if the name of the root element
is "html" (ignoring case considerations). In all other cases the
document type is PDFreactor.DOCTYPE_XML
.public static final int DOCTYPE_XML
public static final int DOCTYPE_XHTML
public static final int DOCTYPE_HTML5
public static final int ENCRYPTION_NONE
public static final int ENCRYPTION_40
public static final int ENCRYPTION_128
public static final String KEYSTORE_TYPE_PKCS12
public static final String KEYSTORE_TYPE_JKS
public static final int SIGNING_MODE_SELF_SIGNED
public static final int SIGNING_MODE_VERISIGN_SIGNED
public static final int SIGNING_MODE_WINCER_SIGNED
public static final int LOG_LEVEL_NONE
public static final int LOG_LEVEL_FATAL
public static final int LOG_LEVEL_WARN
public static final int LOG_LEVEL_INFO
public static final int LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_PERFORMANCE
public static final int JAVASCRIPT_MODE_DISABLED
public static final int JAVASCRIPT_MODE_ENABLED
public static final int JAVASCRIPT_MODE_ENABLED_NO_LAYOUT
public static final int JAVASCRIPT_MODE_ENABLED_REAL_TIME
public static final int JAVASCRIPT_MODE_ENABLED_TIME_LAPSE
JAVASCRIPT_MODE_ENABLED_REAL_TIME
, but is significantly faster.
Only Date.getTime()
is affected by this.public static final int HTTPS_MODE_STRICT
public static final int HTTPS_MODE_LENIENT
public static final String PAGE_ORDER_REVERSE
public static final String PAGE_ORDER_ODD
public static final String PAGE_ORDER_EVEN
public static final String PAGE_ORDER_BOOKLET
public static final String PAGE_ORDER_BOOKLET_RTL
public static final int PAGES_PER_SHEET_DIRECTION_RIGHT_DOWN
public static final int PAGES_PER_SHEET_DIRECTION_LEFT_DOWN
public static final int PAGES_PER_SHEET_DIRECTION_RIGHT_UP
public static final int PAGES_PER_SHEET_DIRECTION_LEFT_UP
public static final int PAGES_PER_SHEET_DIRECTION_DOWN_RIGHT
public static final int PAGES_PER_SHEET_DIRECTION_DOWN_LEFT
public static final int PAGES_PER_SHEET_DIRECTION_UP_RIGHT
public static final int PAGES_PER_SHEET_DIRECTION_UP_LEFT
public static final int MERGE_MODE_APPEND
public static final int MERGE_MODE_PREPEND
public static final int MERGE_MODE_OVERLAY
public static final int MERGE_MODE_OVERLAY_BELOW
public static final int OVERLAY_REPEAT_NONE
public static final int OVERLAY_REPEAT_LAST_PAGE
public static final int OVERLAY_REPEAT_ALL_PAGES
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_SINGLE_PAGE
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_ONE_COLUMN
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_LEFT
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_RIGHT
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_LEFT
public static final int VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_RIGHT
public static final int VIEWER_PREFERENCES_PAGE_MODE_USE_NONE
public static final int VIEWER_PREFERENCES_PAGE_MODE_USE_OUTLINES
public static final int VIEWER_PREFERENCES_PAGE_MODE_USE_THUMBS
public static final int VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
public static final int VIEWER_PREFERENCES_PAGE_MODE_USE_OC
public static final int VIEWER_PREFERENCES_PAGE_MODE_USE_ATTACHMENTS
public static final int VIEWER_PREFERENCES_HIDE_TOOLBAR
public static final int VIEWER_PREFERENCES_HIDE_MENUBAR
public static final int VIEWER_PREFERENCES_HIDE_WINDOW_UI
public static final int VIEWER_PREFERENCES_FIT_WINDOW
public static final int VIEWER_PREFERENCES_CENTER_WINDOW
public static final int VIEWER_PREFERENCES_DISPLAY_DOC_TITLE
public static final int VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_NONE
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
.public static final int VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OUTLINES
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
.public static final int VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_THUMBS
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
.public static final int VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OC
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
.public static final int VIEWER_PREFERENCES_DIRECTION_L2R
public static final int VIEWER_PREFERENCES_DIRECTION_R2L
public static final int VIEWER_PREFERENCES_PRINTSCALING_NONE
public static final int VIEWER_PREFERENCES_PRINTSCALING_APPDEFAULT
public static final int VIEWER_PREFERENCES_DUPLEX_SIMPLEX
public static final int VIEWER_PREFERENCES_DUPLEX_FLIP_SHORT_EDGE
public static final int VIEWER_PREFERENCES_DUPLEX_FLIP_LONG_EDGE
public static final int VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_FALSE
public static final int VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_TRUE
public static final int PROCESSING_PREFERENCES_SAVE_MEMORY_IMAGES
public static final int COLOR_SPACE_RGB
PDFreactor.setDefaultColorSpace(int)
public static final int COLOR_SPACE_CMYK
PDFreactor.setDefaultColorSpace(int)
public static final int EXCEEDING_CONTENT_ANALYZE_NONE
public static final int EXCEEDING_CONTENT_ANALYZE_CONTENT
public static final int EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_STATIC_BOXES
public static final int EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_BOXES
public static final int EXCEEDING_CONTENT_AGAINST_NONE
public static final int EXCEEDING_CONTENT_AGAINST_PAGE_BORDERS
public static final int EXCEEDING_CONTENT_AGAINST_PAGE_CONTENT
public static final int EXCEEDING_CONTENT_AGAINST_PARENT
public static final int CONFORMANCE_PDF
public static final int CONFORMANCE_PDFA1A
public static final int CONFORMANCE_PDFA3A
@Deprecated public static final int CONFORMANCE_PDFA
PDFreactor.CONFORMANCE_PDFA1A
public static final int OUTPUT_FORMAT_PDF
public static final int OUTPUT_FORMAT_JPEG
public static final int OUTPUT_FORMAT_PNG
public static final int OUTPUT_FORMAT_PNG_TRANSPARENT
public static final int OUTPUT_FORMAT_BMP
public static final int OUTPUT_FORMAT_GIF
public static final int OUTPUT_FORMAT_PNG_AI
public static final int OUTPUT_FORMAT_PNG_TRANSPARENT_AI
public static final int OUTPUT_FORMAT_TIFF_LZW
public static final int OUTPUT_FORMAT_TIFF_PACKBITS
public static final int OUTPUT_FORMAT_TIFF_UNCOMPRESSED
public static final int OUTPUT_FORMAT_TIFF_CCITT_1D
public static final int OUTPUT_FORMAT_TIFF_CCITT_GROUP_3
public static final int OUTPUT_FORMAT_TIFF_CCITT_GROUP_4
public PDFreactor()
PDFreactor
.public void setLicenseKey(String content)
String
. If the license key is set
to null
then PDFreactor
looks for a 'licensekey.xml'
file in the same directory where the 'PDFreactor.jar' file is located.
If no license key could be found then PDFreactor runs in evaluation mode.
The default value is null
.
content
- The content of the license key as String
.public void setDisableFontRegistration(boolean value)
Enables or disables the font registration. If font registration is enabled and a valid font cache exists then this font cache will be used. If font registration is disabled, any existing font cache will be ignored and the font directories will be scanned for font information.
The default value is false
.
value
- The new value of the font registration setting.PDFreactor.setCacheFonts(boolean)
,
PDFreactor.setFontCachePath(String)
,
PDFreactor.addFontDirectory(String)
public void setDisableSystemFonts(boolean value)
Enables or disables the use of system fonts. If system fonts are disabled, PDFreactor will neither scan for system fonts nor use the respective font cache.
The default value is false
.
value
- The new value of the system font registration setting.PDFreactor.setDisableFontRegistration(boolean)
,
PDFreactor.addFontDirectory(String)
public void setCacheFonts(boolean value)
Enables or disables caching of font information.
During the PDF creation PDFreactor
requires information about
fonts in the system. The process to get this information takes a
long time, thus PDFreactor offers an option to cache the collected
information about fonts.
A font cache can be reused by PDFreactor
on every PDF creation
process but only if font registration is enabled. If font registration
is disabled then the font cache will be ignored. (see
PDFreactor.setDisableFontRegistration(boolean)
for more information).
The default value is true
.
value
- The new value of the cache fonts setting.PDFreactor.setDisableFontRegistration(boolean)
,
PDFreactor.setFontCachePath(String)
,
PDFreactor.addFontDirectory(String)
public void setFontCachePath(String location)
Sets the path of the font cache. This path will be used to read
and write the font cache. If the font cache path is set to
null
then the "user.home" directory will be used.
The default value is null
.
location
- The path of the font cache.PDFreactor.setDisableFontRegistration(boolean)
,
PDFreactor.setCacheFonts(boolean)
,
PDFreactor.addFontDirectory(String)
@Deprecated public void setFontDirectory(String location)
PDFreactor.addFontDirectory(String)
PDFreactor.addFontDirectory(String)
public void addFontDirectory(String fontDirectory)
Registers an additional font directory to load fonts from.
fontDirectory
- The path of the font directory.public void addFont(String source, String family, boolean bold, boolean italic)
Loads a font from a URL which can be used via the CSS property font-family
.
source
- The URL to load the font from.family
- The font family name the loaded font will be labeled as.bold
- Whether the font will be labeled bold.italic
- Whether the font will be labeled italic.public void addFontAlias(String source, String family, boolean bold, boolean italic)
Registers an alias font family for an existing font.
This function is limited to fonts loaded automatically from system folders.
source
- The name of an existing font family.family
- The alias name for that font.bold
- Whether the alias will be labeled bold.italic
- Whether the alias will be labeled italic.public void setLogLevel(int value)
Sets the log level.
Use one of the LOG_LEVEL_
constants to specify the log
level.
The default value is PDFreactor.LOG_LEVEL_NONE
.
value
- The new log level setting.PDFreactor.LOG_LEVEL_NONE
,
PDFreactor.LOG_LEVEL_FATAL
,
PDFreactor.LOG_LEVEL_WARN
,
PDFreactor.LOG_LEVEL_INFO
,
PDFreactor.LOG_LEVEL_DEBUG
,
PDFreactor.LOG_LEVEL_PERFORMANCE
,
PDFreactor.getLog()
public void setLogExceedingContent(int logExceedingContentAnalyze, int logExceedingContentAgainst)
Whether to log content exceeding the page.
Use EXCEEDING_CONTENT_ANALYZE_
constants to specify
which kind of content should be observed for exceeding content logging.
The default value is PDFreactor.EXCEEDING_CONTENT_ANALYZE_NONE
.
Use EXCEEDING_CONTENT_AGAINST_
constants to specify
that exceeding this content starts exceeding content logging.
The default value is PDFreactor.EXCEEDING_CONTENT_AGAINST_NONE
.
logExceedingContentAnalyze
- Enables logging of exceeding content
and optionally of boxes.logExceedingContentAgainst
- Enables logging of exceeding content
either against the page edges, page
content areas or containers.PDFreactor.EXCEEDING_CONTENT_ANALYZE_NONE
,
PDFreactor.EXCEEDING_CONTENT_ANALYZE_CONTENT
,
PDFreactor.EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_BOXES
,
PDFreactor.EXCEEDING_CONTENT_ANALYZE_CONTENT_AND_STATIC_BOXES
,
PDFreactor.EXCEEDING_CONTENT_AGAINST_NONE
,
PDFreactor.EXCEEDING_CONTENT_AGAINST_PARENT
,
PDFreactor.EXCEEDING_CONTENT_AGAINST_PAGE_CONTENT
,
PDFreactor.EXCEEDING_CONTENT_AGAINST_PAGE_BORDERS
public void setThrowLicenseExceptions(boolean throwLicenseExceptions)
Whether an exception should be thrown when no legal full license key is set. This allows to programmatically ensure that documents are not altered due to license issues.
The default value is false
.
public void setBaseURL(String value)
Sets the base URL
of the XML document.
To resolve relative URLs to absolute URLs a reference (base) URL is required. This reference URL is usually the system id of the document.
This method can be used to specify another reference URL. If this URL
is not null
then it will be used instead of the system
id.
The default value is null
.
value
- The base URL for the document.public void setXSLTMode(boolean value)
Enables or disables XSLT transformations.
Set this value to true
to enable XSLT transformations or
to false
to disable XSLT transformations.
The default value is false
.
value
- The new XSLT mode.public void setEncoding(String value)
Sets the encoding of the document.
If this value is set to null
or it is empty then the
encoding will be detected automatically.
The default value is null
.
value
- The encoding of the document or null
for
autodetection.public void setCleanupTool(int value)
Sets the cleanup tool to use for documents with unparsable content.
The CLEANUP_
constants can be used as value. The
default value specified is PDFreactor.CLEANUP_CYBERNEKO
.
The cleanup tool is only used for DOCTYPE_XHTML. HTML5 utilizes an internal cleanup.
value
- The new cleanup tool.PDFreactor.CLEANUP_NONE
,
PDFreactor.CLEANUP_JTIDY
,
PDFreactor.CLEANUP_CYBERNEKO
,
PDFreactor.CLEANUP_TAGSOUP
public void setJavaScriptMode(int javaScriptMode)
Sets the JavaScript Mode.
The default value specified is PDFreactor.JAVASCRIPT_MODE_DISABLED
.
javaScriptMode
- The JavaScript mode.PDFreactor.JAVASCRIPT_MODE_ENABLED
,
PDFreactor.JAVASCRIPT_MODE_DISABLED
public void setHTTPSMode(int httpsMode)
Sets the HTTPS mode. In closed environment lenient can be the preferred setting to avoid HTTPS issues that are not security critical
The default value specified is PDFreactor.HTTPS_MODE_STRICT
.
httpsMode
- The HTTPS Mode.PDFreactor.HTTPS_MODE_STRICT
,
PDFreactor.HTTPS_MODE_LENIENT
public void setDocumentType(int value)
Sets the document type.
The DOCTYPE_
constants can be used to specify the
document type. The default value specified is
PDFreactor.DOCTYPE_AUTODETECT
.
value
- The new document type setting.PDFreactor.DOCTYPE_AUTODETECT
,
PDFreactor.DOCTYPE_XML
,
PDFreactor.DOCTYPE_XHTML
,
PDFreactor.DOCTYPE_HTML5
public void setPostTransformationDocumentType(int value)
Sets the document type after the XSL-Transformations have been applied.
The DOCTYPE_
constants can be used to specify the
document type. The default value specified is
PDFreactor.DOCTYPE_AUTODETECT
.
value
- The new document type setting.PDFreactor.DOCTYPE_AUTODETECT
,
PDFreactor.DOCTYPE_XML
,
PDFreactor.DOCTYPE_XHTML
,
PDFreactor.DOCTYPE_HTML5
,
PDFreactor.setDocumentType(int)
public void addUserStyleSheet(InputSource inputSource) throws IOException
Adds a user style sheet to the document.
The specified input source will be loaded and then added.
inputSource
- The InputSource
of the style sheet.IOException
- If the style sheet could not be loaded.PDFreactor.addUserStyleSheet(String,String,String,String)
,
PDFreactor.removeAllUserStyleSheets()
public void addIntegrationStyleSheet(InputSource inputSource) throws IOException
Adds a integration style sheet to the document.
The specified input source will be loaded and then added.
inputSource
- The InputSource
of the style sheet.IOException
- If the style sheet could not be loaded.PDFreactor.addIntegrationStyleSheet(String,String,String,String)
,
PDFreactor.removeAllIntegrationStyleSheets()
public void addUserStyleSheet(String content, String media, String title, String uri)
Adds a user style sheet to the document.
There are two ways to specify the style sheet:
content
- The content of the style sheet.media
- The media type of the style sheet.title
- The title of the style sheet.uri
- The URI of the style sheet.PDFreactor.addUserStyleSheet(InputSource)
,
PDFreactor.removeAllUserStyleSheets()
public void addIntegrationStyleSheet(String content, String media, String title, String uri)
Adds an integration style sheet to the document.
There are two ways to specify the style sheet:
content
- The content of the style sheet.media
- The media type of the style sheet.title
- The title of the style sheet.uri
- The URI of the style sheet.PDFreactor.addIntegrationStyleSheet(InputSource)
,
PDFreactor.removeAllIntegrationStyleSheets()
public void removeAllUserStyleSheets()
Removes all user style sheets.
public void removeAllIntegrationStyleSheets()
Removes all integration style sheets.
public void addXSLTStyleSheet(String content, String uri)
Adds an XSLT style sheet to the document.
There are two ways to specify the style sheet:
content
- The content of the style sheet.uri
- The URI of the style sheet.PDFreactor.removeAllXSLTStyleSheets()
public void removeAllXSLTStyleSheets()
Removes all XSLT style sheets.
public void addUserScript(String content, String uri, boolean beforeDocumentScripts)
Adds an user script to the document.
There are two ways to specify the script:
content
- The content of the script.uri
- The URI of the script.beforeDocumentScripts
- Use true
to cause PDFreactor to run the
script before all scripts inside the document and false
to run it after.PDFreactor.removeAllUserScripts()
public void removeAllUserScripts()
Removes all user scripts.
public void setAuthor(String value)
Sets the value of the author field of the PDF document.
value
- The author of the document.public void setCreator(String value)
Sets the value of creator field of the PDF document.
value
- The creator of the document.public void setKeywords(String value)
Sets the value of the keywords field of the PDF document.
value
- The keywords of the document.public void setTitle(String value)
Sets the value of the title field of the PDF document.
value
- The title of the document.public void setSubject(String value)
Sets the value of the subject field of the PDF document.
value
- The subject of the document.public void addCustomDocumentProperty(String name, String value)
Adds a custom property to the PDF document. An existing property of the same name will be replaced.
name
- The name of the propertyvalue
- The value of the propertypublic void addAttachment(byte[] data, String url, String name, String description)
Adds a file attachment to PDF document.
data
- The binary content of the attachment. May be null
.url
- If data
is null
, the attachment will be retrieved from this URL
.
If this is "#" the input document URL is used instead.name
- The file name associated with the attachment. It is recommended to specify
the correct file extension. If this is null
the name is derived from the URL
.description
- The description of the attachment. If this is null
the name
is used.public void setDocumentDefaultLanguage(String languageCode)
Sets the language used for documents having no explicit language attribute set.
The language code is used to resolve the lang() selector correct and to determine the correct language used for hyphenation.languageCode
- the default ISO 639 language code used for documents.public void setEncryption(int value)
Sets the encryption.
Use one of the ENCRYPTION_
constants to specify the
encryption. The default value is PDFreactor.ENCRYPTION_NONE
.
value
- The new encryption setting.PDFreactor.ENCRYPTION_NONE
,
PDFreactor.ENCRYPTION_40
,
PDFreactor.ENCRYPTION_128
,
PDFreactor.setOwnerPassword(String)
,
PDFreactor.setUserPassword(String)
,
PDFreactor.setAllowAnnotations(boolean)
,
PDFreactor.setAllowAssembly(boolean)
,
PDFreactor.setAllowCopy(boolean)
,
PDFreactor.setAllowDegradedPrinting(boolean)
,
PDFreactor.setAllowFillIn(boolean)
,
PDFreactor.setAllowModifyContents(boolean)
,
PDFreactor.setAllowPrinting(boolean)
,
PDFreactor.setAllowScreenReaders(boolean)
public void setFullCompression(boolean value)
Enables or disables full compression of the PDF document.
The default value is false
.
value
- Use true
to enable full compression of the
document and false
to disable full compression.public void setOwnerPassword(String value)
Sets the owner password of the PDF document.
The default value is null
.
value
- The new owner password.PDFreactor.setEncryption(int)
,
PDFreactor.setUserPassword(String)
public void setUserPassword(String value)
Sets the user password of the PDF document.
The default value is null
.
value
- The new user password.PDFreactor.setEncryption(int)
,
PDFreactor.setOwnerPassword(String)
public void setAddLinks(boolean value)
Enables or disables links in the PDF document.
The default value is false
.
value
- Use true
to enable links in the document
and false
to disable links.public void setAddBookmarks(boolean value)
Enables or disables bookmarks in the PDF document.
The default value isfalse
.value
- Use true
to enable bookmarks in the document
and false
to disable bookmarks.public void setAddTags(boolean value)
Enables or disables tagging of the PDF document.
The default value is false
.
value
- Use true
to enable tagging of the document
and false
to disable tagging.public void setAddComments(boolean value)
Enables or disables comments in the PDF document.
The default value is false
.
value
- Use true
to enable comments in the document
and false
to disable comments.public void setAddPreviewImages(boolean value)
Enables or disables embedding of image previews per page in the PDF document.
The default value is false
.
value
- Use true
to enable embedding of image previews
per page in the document and false
to disable embedding of
image previews per page.public void setAddAttachments(boolean value)
Enables or disables attachments specified in style sheets.
The default value is false
.
value
- Whether to enable CSS based attachments.public void setAddOverprint(boolean value)
Enables or disables overprinting.
The default value is false
.
value
- Whether to enable overprinting.public void setPrintDialogPrompt(boolean value)
Enables or disables a print dialog to be shown upon opening the generated PDF document by a PDF viewer.
The default value is false
.
value
- Use true
to enable a print dialog to be shown
upon document opening by a PDF viewer
and false
to disable the print dialog prompt.public void setAppendLog(boolean value)
Specifies whether or not the log data should be added to the PDF document.
The default value is false
.
value
- Use true
to add the log data to the document
and false
if the log data should not be added.public void setAllowAnnotations(boolean value)
Enables or disables the 'annotations' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'annotations' in the document
and false
to disable 'annotations'.PDFreactor.setEncryption(int)
public void setAllowAssembly(boolean value)
Enables or disables the 'assembly' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'assembly' in the document
and false
to disable 'assembly'.PDFreactor.setEncryption(int)
public void setAllowCopy(boolean value)
Enables or disables the 'copy' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'copy' in the document
and false
to disable 'copy'.PDFreactor.setEncryption(int)
public void setAllowDegradedPrinting(boolean value)
Enables or disables the 'degraded printing' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'degraded printing' in
the document and false
to disable 'degraded printing'.PDFreactor.setEncryption(int)
public void setAllowFillIn(boolean value)
Enables or disables the 'fill in' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'fill in' in the document
and false
to disable 'fill in'.PDFreactor.setEncryption(int)
public void setAllowModifyContents(boolean value)
Enables or disables the 'modify contents' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'modify contents' in the
document and false
to disable 'modify contents'.PDFreactor.setEncryption(int)
public void setAllowPrinting(boolean value)
Enables or disables the 'printing' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'printing' in the document
and false
to disable 'printing'.PDFreactor.setEncryption(int)
public void setAllowScreenReaders(boolean value)
Enables or disables the 'screen readers' restriction in the PDF document.
The default value is false
.
value
- Use true
to enable 'screen readers' in the
document and false
to disable 'screen readers'.PDFreactor.setEncryption(int)
public void setDisableFontEmbedding(boolean disableFontEmbedding)
Sets whether fonts will not be embedded into the resulting PDF. Setting this to true will reduce the file size of the output document. However, the resulting PDF documents are no longer guaranteed to look identical on all systems.
The default value is false
.
public void setFontFallback(String[] fontFallback)
Sets a list of fallback font families used for character substitution. This
list is iterated for characters that can not be displayed with any of the fonts
specified via the CSS property font-family
.
fontFallback
- an array of font family namespublic void setPixelsPerInch(int ppi)
Sets the pixels per inch.
Changing this value changes the physical length of sizes specified in px (including those specified via HTML attributes).
The default value is 96ppi
.
ppi
- The pixels per inch.public void setPixelsPerInchShrinkToFit(boolean pixelsPerInchShrinkToFit)
Whether the pixels per inch should be adapted automatically to avoid content exceeding pages.
public void setMergeMode(int mode)
Sets the merge mode.
The following merge methods can be used:
PDFreactor.MERGE_MODE_APPEND
)PDFreactor.MERGE_MODE_PREPEND
)PDFreactor.MERGE_MODE_OVERLAY
)PDFreactor.MERGE_MODE_OVERLAY_BELOW
)The default value is PDFreactor.MERGE_MODE_APPEND
.
mode
- The merge mode.PDFreactor.MERGE_MODE_APPEND
,
PDFreactor.MERGE_MODE_PREPEND
,
PDFreactor.MERGE_MODE_OVERLAY
,
PDFreactor.MERGE_MODE_OVERLAY_BELOW
public void setMergeURL(String url)
This method sets a URL of an external PDF document which will be merged with the PDF document generated by the XML source.
public void setMergeURLs(String[] urls)
This method sets an array of URLs of external PDF documents which will be merged with the PDF document generated by the XML source.
public void setMergeByteArray(byte[] array)
This method sets a byte array containing an external PDF document which will be merged with the PDF document generated by the XML source.
public void setMergeByteArrays(byte[][] arrays)
This method sets an array of byte arrays that contain multiple external PDFs which will be merged with the PDF document generated by the XML source.
.@Deprecated public final void setMergeBeforePDF(boolean value)
PDFreactor.setMergeMode(int)
PDFreactor.setMergeMode(int)
public void setOverlayRepeat(int overlayRepeat)
If one of the documents of an overlay process is shorter than the other, this method allows repeating either its last page or all of its pages in order to overlay all pages of the longer document.
Use one of the OBERLAY_REPEAT_
constants to specify the
overlay repeat. The default value is PDFreactor.OVERLAY_REPEAT_NONE
.
public void setPageOrder(String order)
Sets the page order of the direct result of the conversion.
order
- A comma-separated list of page numbers and ranges is
intended as parameter. Alternatively, PAGE_ORDER_
constants can be used.PDFreactor.PAGE_ORDER_EVEN
,
PDFreactor.PAGE_ORDER_ODD
,
PDFreactor.PAGE_ORDER_BOOKLET
,
PDFreactor.PAGE_ORDER_BOOKLET_RTL
public void setPagesPerSheetProperties(int cols, int rows, String sheetSize, String sheetMargin, String spacing, int direction)
Sets the properties of a sheet on which multiple pages are being arranged.
If cols
or rows
is less than 1, no
pages-per-sheet processing is done. This is the case by default.
Use one of the PAGES_PER_SHEET_DIRECTION_
constants to
specify the the direction. The default value is PDFreactor.PAGES_PER_SHEET_DIRECTION_RIGHT_DOWN
.
cols
- The number of columns per sheet.rows
- The number of rows per sheet.sheetSize
- The sheet size as CSS size, e.g. A4
, letter landscape
, 15in 20in
,
20cm 30cm
.sheetMargin
- The sheet margin as CSS margin, e.g. 1in
, 1cm 1.5cm
, 10mm 20mm 10mm 30mm
. null
is
interpreted as 0mm
.spacing
- The horizontal and vertical space between pages on a sheet as CSS value, e.g. 0.1in
, 5mm 2mm
. null
is
interpreted as 0mm
.direction
- The direction in which the pages are ordered on a sheet.PDFreactor.PAGES_PER_SHEET_DIRECTION_DOWN_LEFT
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_DOWN_RIGHT
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_LEFT_DOWN
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_LEFT_UP
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_RIGHT_DOWN
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_RIGHT_UP
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_UP_LEFT
,
PDFreactor.PAGES_PER_SHEET_DIRECTION_UP_RIGHT
public void setBookletMode(String sheetSize, String sheetMargin, boolean rtl)
Convenience method to set pages-per-sheet properties and page order in one step to create a booklet.
sheetSize
- The size of the sheet as CSS value, e.g. A3
,
letter landscape
, 15in 20in
,
20cm 30cm
.sheetMargin
- The sheet margin as CSS margin value, e.g.
1in
, 1cm 1.5cm
, 10mm
20mm 10mm 30mm
.
null
is interpreted as 0mm
.rtl
- Whether or not the reading order of the booklet should be
right-to-left.public void setViewerPreferences(int viewerPreferences)
Sets the page layout and page mode preferences of the PDF.
Use the VIEWER_PREFERENCES_
constants to specify the
viewer preferences. By default no viewer preference is set.
viewerPreferences
- A value of ORed VIEWER_PREFERENCES_
constants.PDFreactor.VIEWER_PREFERENCES_CENTER_WINDOW
,
PDFreactor.VIEWER_PREFERENCES_DIRECTION_L2R
,
PDFreactor.VIEWER_PREFERENCES_DIRECTION_R2L
,
PDFreactor.VIEWER_PREFERENCES_DISPLAY_DOC_TITLE
,
PDFreactor.VIEWER_PREFERENCES_DUPLEX_FLIP_LONG_EDGE
,
PDFreactor.VIEWER_PREFERENCES_DUPLEX_FLIP_SHORT_EDGE
,
PDFreactor.VIEWER_PREFERENCES_DUPLEX_SIMPLEX
,
PDFreactor.VIEWER_PREFERENCES_FIT_WINDOW
,
PDFreactor.VIEWER_PREFERENCES_HIDE_MENUBAR
,
PDFreactor.VIEWER_PREFERENCES_HIDE_TOOLBAR
,
PDFreactor.VIEWER_PREFERENCES_HIDE_WINDOW_UI
,
PDFreactor.VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_NONE
,
PDFreactor.VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OC
,
PDFreactor.VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_OUTLINES
,
PDFreactor.VIEWER_PREFERENCES_NON_FULLSCREEN_PAGE_MODE_USE_THUMBS
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_ONE_COLUMN
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_SINGLE_PAGE
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_LEFT
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_COLUMN_RIGHT
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_LEFT
,
PDFreactor.VIEWER_PREFERENCES_PAGE_LAYOUT_TWO_PAGE_RIGHT
,
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_FULLSCREEN
,
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_USE_NONE
,
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_USE_OC
,
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_USE_OUTLINES
,
PDFreactor.VIEWER_PREFERENCES_PAGE_MODE_USE_THUMBS
,
PDFreactor.VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_FALSE
,
PDFreactor.VIEWER_PREFERENCES_PICKTRAYBYPDFSIZE_TRUE
,
PDFreactor.VIEWER_PREFERENCES_PRINTSCALING_APPDEFAULT
,
PDFreactor.VIEWER_PREFERENCES_PRINTSCALING_NONE
public void setConformance(int conformance)
Sets the conformance of the PDF.
The CONFORMANCE_
constants can be used as value. The default
value specified is PDFreactor.CONFORMANCE_PDF
.
conformance
- Any of the conformance constants.PDFreactor.CONFORMANCE_PDF
,
PDFreactor.CONFORMANCE_PDFA
public void setDefaultColorSpace(int defaultColorSpace)
Sets whether to convert color key words to CMYK instead of RGB.
The COLOR_SPACE_
constants can be used as value.
The default value specified is PDFreactor.COLOR_SPACE_RGB
.
defaultColorSpace
- the default color space of the PDFPDFreactor.COLOR_SPACE_CMYK
,
PDFreactor.COLOR_SPACE_RGB
public void setOutputIntentFromURL(String identifier, String profileUrl)
Sets the output intent including the identifier and the ICC profile to be embedded into the PDF.
identifier
- the OutputConditionIdentifierprofileUrl
- the DestOutputProfilepublic void setOutputIntentFromByteArray(String identifier, byte[] profileData)
Sets the output intent including the identifier and the ICC profile to be embedded into the PDF.
identifier
- the OutputConditionIdentifierprofileData
- the DestOutputProfilepublic void setProcessingPreferences(int processingPreferences)
Preferences that influence the conversion process without changing the output
Use the PROCESSING_PREFERENCES_
constants to specify the
processing preferences. By default no processing preference is set.
processingPreferences
- A value of ORed processing preferences flags.PDFreactor.PROCESSING_PREFERENCES_SAVE_MEMORY_IMAGES
public void setAuthenticationCredentials(String username, String password)
Enables access to resources that are secured via Basic or Digest authentication.
username
- The user name for the secured realm.password
- The password for the secured realm.public void setRequestHeader(String key, String value)
Adds a request header to all outgoing HTTP connections. If the key already exists, the pair is overwritten.
key
- The key of the header.value
- The value of the header.public void setCookie(String key, String value)
Adds a cookie to all outgoing HTTP connections.
The parameters are URL encoded (see setRawCookie
).
If the key already exists, the pair is overwritten.
key
- The key of the cookie.value
- The value of the cookie.PDFreactor.setRawCookie(String, String)
public void setRawCookie(String key, String value)
Adds a cookie to all outgoing HTTP connections.
The parameters are not URL encoded (see setCookie
).
If the key already exists, the pair is overwritten.
key
- The key of the cookie.value
- The value of the cookie.PDFreactor.setCookie(String, String)
public void setSignPDF(String keystoreURL, String keyAlias, String keystorePassword, String keystoreType, int signingMode)
Sets a digital certificate to sign the newly created PDF.
Requires a keystore file. The included certificate may be self-signed.
Use the KEYSTORE_TYPE_
constants to specify the keystore type.
Use the SIGNING_MODE_
constants to specify the signing mode.
keystoreURL
- The URL to the keystore file.keyAlias
- The alias of the certificate included in the keystore to be used to sign the PDF.keystorePassword
- The password of the keystore.keystoreType
- The format of the keystore, i.e. pkcs12
or jks
.
Use one of the KEYSTORE_TYPE_
constants as value.signingMode
- The mode that is used to sign the PDF, i.e. self-signed
,
Windows certificate
or VeriSign
.
Use one of the SIGNING_MODE_
constants as value.PDFreactor.KEYSTORE_TYPE_JKS
,
PDFreactor.KEYSTORE_TYPE_PKCS12
,
PDFreactor.SIGNING_MODE_SELF_SIGNED
,
PDFreactor.SIGNING_MODE_VERISIGN_SIGNED
,
PDFreactor.SIGNING_MODE_WINCER_SIGNED
public void setOutputFormat(int format, int outputWidth, int outputHeight)
PDF.
For image formats the width or height in pixels must be specified.
When either dimension is <1 it is computed based on the other dimension and the aspect ratio of the input document.
format
- the output format. See OUTPUT_FORMAT_
constantsoutputWidth
- The with of the output in pixels (image formats only). Values <1 will be computed based on the specified height and the aspect ratio of the input document.outputHeight
- The height of the output in pixels (image formats only). Values <1 will be computed based on the specified width and the aspect ratio of the input document.PDFreactor.OUTPUT_FORMAT_PDF
,
PDFreactor.OUTPUT_FORMAT_JPEG
,
PDFreactor.OUTPUT_FORMAT_PNG
,
PDFreactor.OUTPUT_FORMAT_PNG_TRANSPARENT
,
PDFreactor.OUTPUT_FORMAT_BMP
,
PDFreactor.OUTPUT_FORMAT_GIF
,
PDFreactor.OUTPUT_FORMAT_PNG_AI
,
PDFreactor.OUTPUT_FORMAT_PNG_TRANSPARENT_AI
,
PDFreactor.OUTPUT_FORMAT_TIFF_LZW
,
PDFreactor.OUTPUT_FORMAT_TIFF_PACKBITS
,
PDFreactor.OUTPUT_FORMAT_TIFF_UNCOMPRESSED
,
PDFreactor.OUTPUT_FORMAT_TIFF_CCITT_1D
,
PDFreactor.OUTPUT_FORMAT_TIFF_CCITT_GROUP_3
,
PDFreactor.OUTPUT_FORMAT_TIFF_CCITT_GROUP_4
public void setContinuousOutput(int width, int height)
width
- equivalent to the width of a browser window (view port). Values <1 enable paginated outputheight
- equivalent to the height of a browser window (view port). For values <1 the entire height of the document is used.public void enableDebugMode()
public void renderDocument(InputSource inputSource, OutputStream outputStream) throws SAXException, IOException, TransformerException
Generates a PDF document from an InputSource
.
The resulting PDF document will be written into an OutputStream
.
inputSource
- The InputSource
of the XML document.outputStream
- The OutputStream
where the PDF RAW data will be
written into.TransformerException
com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
PDFreactor.renderDocumentFromURL(String)
,
PDFreactor.renderDocumentFromByteArray(byte[])
,
PDFreactor.renderDocumentFromContent(String)
public byte[] renderDocumentFromURL(String url) throws SAXException, IOException, TransformerException
Generates a PDF document or an image from an HTML or XML document at a URL.
url
- A URL pointing to the input document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromByteArray(byte[])
,
PDFreactor.renderDocumentFromContent(String)
,
PDFreactor.renderDocumentFromURLAsArray(String)
public byte[][] renderDocumentFromURLAsArray(String url) throws SAXException, IOException, TransformerException
Generates an array of byte-arrays each containing an image representing one page of the document from an HTML or XML document at a URL.
url
- A URL pointing to the input document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromByteArrayAsArray(byte[])
,
PDFreactor.renderDocumentFromContentAsArray(String)
,
PDFreactor.renderDocumentFromURL(String)
public byte[] renderDocumentFromByteArray(byte[] array) throws SAXException, IOException, TransformerException
Generates a PDF document or an image from an HTML or XML document inside a byte-array.
array
- An array containing the content of the HTML or XML document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromURL(String)
,
PDFreactor.renderDocumentFromContent(String)
,
PDFreactor.renderDocumentFromByteArrayAsArray(byte[])
public byte[][] renderDocumentFromByteArrayAsArray(byte[] array) throws SAXException, IOException, TransformerException
Generates an array of byte-arrays each containing an image representing one page of the document from an HTML or XML document inside a byte-array.
array
- An array containing the content of the HTML or XML document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromURLAsArray(String)
,
PDFreactor.renderDocumentFromContentAsArray(String)
,
PDFreactor.renderDocumentFromByteArray(byte[])
public byte[] renderDocumentFromContent(String content) throws SAXException, IOException, TransformerException
Generates a PDF document or an image from an HTML or XML document inside a String.
content
- A String containing the content of the HTML or XML document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromByteArray(byte[])
,
PDFreactor.renderDocumentFromURL(String)
,
PDFreactor.renderDocumentFromContentAsArray(String)
public byte[][] renderDocumentFromContentAsArray(String content) throws SAXException, IOException, TransformerException
Generates an array of byte-arrays each containing an image representing one page of the document from an HTML or XML document inside a String.
array
- An String containing the content of the HTML or XML document.com.realobjects.pdfreactor.Exceptions.PDFreactorException
IOException
SAXException
TransformerException
PDFreactor.renderDocumentFromByteArrayAsArray(byte[])
,
PDFreactor.renderDocumentFromURLAsArray(String)
,
PDFreactor.renderDocumentFromContent(String)
public void addProgressEventListener(ProgressEventListener listener)
Adds a ProgressEventListener
.
listener
- The ProgressEventListener
to add.PDFreactor.removeProgressEventListener(ProgressEventListener)
public void removeProgressEventListener(ProgressEventListener listener)
Removes a ProgressEventListener
.
listener
- The ProgressEventListener
to remove.PDFreactor.addProgressEventListener(ProgressEventListener)
public void setLogger(Logger object)
Sets a Logger
to receive log messages.
The default value is null
.
object
- The Logger
to use.PDFreactor.getLogger()
public Logger getLogger()
Returns the Logger
used by this PDFreactor
.
Logger
.PDFreactor.setLogger(Logger)
public String getError()
Returns the error messages generated during rendering.
String
.public String getLog()
Returns the log messages generated during rendering based on the log level.
String
.PDFreactor.setLogLevel(int)
public ExceedingContent[] getExceedingContents()
Provides information about content exceeding its page or parent. Depends on the mode set via PDFreactor.setLogExceedingContent(int, int)
.
ExceedingContent
objects
or null
if the logging of exceeding content was not enabled
or no conversion was run, yet.public int getNumberOfPages(boolean pdf)
Returns the number of pages of the document after conversion.
The result returned by this method will only be correct if the document has already been laid out by one of the render methods.
pdf
- If true
, returns the number of pages of the
resulting PDF (including, e.g., merge operations), otherwise
it will return the number pages of the laid out input document.This doc was generated on 2015-03-24. Copyright © 2002-2015 RealObjects GmbH. All Rights Reserved.