Class PD4ML
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
boolean
boolean
static final String
boolean
boolean
static final String
Fields inherited from class org.zefer.pd4ml.PD4Constants
A0, A1, A10, A2, A3, A4, A5, A6, A7, A8, A9, AllowAnnotate, AllowAssembly, AllowContentExtraction, AllowCopy, AllowDegradedPrint, AllowFillingForms, AllowModify, AllowPrint, ArchA, ArchB, ArchC, ArchD, ArchE, ArchE1, DefaultPermissions, HALFLETTER, ISOB0, ISOB1, ISOB2, ISOB3, ISOB4, ISOB5, LEDGER, LEGAL, LETTER, NOTE, PD4ML_ABSOLUTE_ADDRESS_SPACE, PD4ML_ALLOWED_RESOURCE_LOCATION, PD4ML_BACKGROUND_AS_PATTERNS, PD4ML_BASIC_AUTHENTICATION, PD4ML_CACHE_ENABLE, PD4ML_CACHE_IMAGES_IN_TMP_DIR, PD4ML_CONFIG_FILE, PD4ML_CONFIG_HANDLER_CLASS, PD4ML_CSS_IMPORT_DIRECTIVE, PD4ML_DISABLE_EXTERNAL_ATTACHMENTS, PD4ML_DOCUMENT_DATE, PD4ML_DOCUMENT_HEIGHT_PX, PD4ML_DOCUMENT_VIEW_MODE, PD4ML_DOCUMENT_XMP_DATE, PD4ML_ENABLE_CANVAS_INTERPRETER, PD4ML_ENABLE_HTTP_ERRORS, PD4ML_EXTERNAL_CANVAS_HANDLER, PD4ML_EXTRA_RESOURCE_LOADERS, PD4ML_FAKE_BROWSER, PD4ML_FIX20130116, PD4ML_FIX20150816, PD4ML_FORCE_RTL, PD4ML_GENERATE_TOOLTIPS, PD4ML_HEADER_HEIGHT_LIMIT, PD4ML_HTTP_PROXY, PD4ML_HTTP_REQUEST_DISPATCHER, PD4ML_IDS_AS_DESTINATIONS, PD4ML_IMAGE_REPOSITORY, PD4ML_INFO_AUTHOR, PD4ML_INFO_TITLE, PD4ML_INITIAL_PAGE_NUMBER, PD4ML_LEGACY_RTL_MODE, PD4ML_LEGACY_TEXT_BASELINE_COMPUTATION, PD4ML_MEDIA_TYPE_PRINT, PD4ML_MOBILE_DEVICE_OPTIMIZE, PD4ML_MOBILE_DEVICE_WIDTH, PD4ML_PDFA_STATUS, PD4ML_PRINT_DIALOG_POPUP, PD4ML_RIGHT_EDGE_PX, PD4ML_SESSIONID_APPEND, PD4ML_SESSIONID_VARNAME, PD4ML_SOCKET_TIMEOUT, PD4ML_STYLESHEETS_TO_OMIT, PD4ML_SUPPRESS_BLANK_PAGES, PD4ML_TOTAL_PAGES, PDF, PDFA, PNG24, PNG8, RTF, RTF_WMF, TABLOID, TIFF, TIFF_COMPRESSED, TRANSLATE_FACTOR
-
Constructor Summary
ConstructorsConstructorDescriptionPD4ML()
PD4ML Constructor Creates and initializes an instance of the rendering engine -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDocumentActionHandler
(String actionType, String javaScript) method defines JavaScript action handler for generated document.void
addMetadata
(String key, String value, boolean hide) The method defines custom properties for PDF document meta data.final void
Apply additional stylesheet to the documentfinal void
Apply additional stylesheet to the documentvoid
sets htmlWidth to the most right margin of the HTML block content.rotates given page format by 90 degrees.
Make sure that after rotating of standard page formats from PD4Constants you pass the new dimensions to setPageSize() (not setPageSizeMM())void
removes all objects (images, CSS, etc) from internal caches.static void
debug() utility methodvoid
if triggered, PD4ML does not generate active hyperlinks in resulting PDF.void
enables an output of debug messages.void
enableImgSplit
(boolean split) allows to disable image splitting by page breaks.void
enableRenderingPatch
(boolean patch) Deprecated.no patching is neededvoid
enableSmartTableBreaks
(boolean enable) The method switches on/off the experimental table break feature.void
enableTableBreaks
(boolean enable) Deprecated.void
forces PD4ML to downscale entire HTML layout to fit a single PDF page vertically.void
fitPageVertically
(boolean center) void
generateMulticolumn
(int columns, int span, boolean millimeters) switches PD4ML into multicolumn mode.void
generateOutlines
(boolean fromHeadings) if triggered, than PD4ML generates PDF bookmarks (aka outlines).final void
generatePdfa
(boolean enable) Forces PD4ML to output PDF compliant with PDF/A specification.void
generatePdfForms
(boolean enable, String useTtfFont) forces PD4ML to convert HTML forms into PDF forms (Acroforms).getCache()
getLastRenderInfo
(String key) returns statistics for the last render() callstatic String
getVersion() returns current version numberprotected int
inlineHtmlHeaderHeight
(PageHeaderElement header, String title, int pageNumber, Map data, int maxHeight, int htmlWidth, int generation) Measures height of header or footer (defined inline).final void
interpolateImages
(boolean mode) enables or disables image interpolationstatic final boolean
returns true if the library is used in evaluation modestatic final boolean
isPro()
returns true if it is Pro version of the libraryvoid
merge
(InputStream input, int fromPage, int toPage, boolean append) Merges conversion result with an already existing PDF documentvoid
Merges conversion result with an already existing PDF documentvoid
monitorProgress
(PD4ProgressListener listener) conversion progress callback supportvoid
outputFormat
(String format) void
outputFormat
(String format, int width, int height) void
outputRange
(String description) void
overrideDocumentEncoding
(String encoding) sets default encoding for URL-addressed HTML documentsstatic final int
predictPageHeight
(Insets pageInsets, Dimension pageSize, int userSpace) static final float
predictScale
(Insets pageInsets, Dimension pageSize, int userSpace) protected void
printBackground
(PD4Device gd, PD4PageMark header, PD4PageMark footer, URL base, int pageNumber, ResourceCache cache) protected void
printHtmlHeaderAndFooter
(PD4Device gd, PD4PageMark header, PD4PageMark footer, String title, URL base, int userSpaceWidth, int totalPages, int pageNumber, String encoding, ResourceCache cache, double scaleFactor) protected void
printInlineHtmlHeaderOrFooter
(PD4Device gd, boolean isFooter, PageHeaderElement inlineHeader, String title, int totalPages, int pageNumber, Map data, int maxHeight, int htmlWidth, int generation, Vector footnotes) Prints header or footer (defined inline) whose height can vary from page to page.protected void
printInlineRtfHeaderOrFooter
(PD4RtfDevice gd, PageHeaderElement inlineHeader, String title, Map data, int htmlWidth, int generation) Prints header or footer (defined inline) whose height can vary from page to page.protected void
printRtfHeaderOrFooter
(PD4RtfDevice gd, PD4PageMark header, String title, URL base, int userSpaceWidth, String encoding, ResourceCache cache, double scaleFactor, boolean firstPage) void
makes PD4ML to output PDF objects respecting dimensions/font sizes given in "in", "pt", "cm" etc.void
render
(InputStreamReader isr, OutputStream os) converts input data to PDFvoid
render
(InputStreamReader isr, OutputStream os, URL base) converts input data to PDF.void
render
(StringReader[] isrs, OutputStream os, URL base) converts input data to PDFvoid
render
(StringReader isr, OutputStream os) converts input data to PDFvoid
render
(StringReader isr, OutputStream os, URL base) converts input data to PDFvoid
render
(StringReader isr, OutputStream os, URL base, String encoding) converts input data to PDFvoid
render
(String textUrl, OutputStream os) input data referred by URL to PDFvoid
render
(URL[] urls, OutputStream os) converts input data referred by URLs to PDFvoid
render
(URL url, OutputStream os) converts input data referred by URL to PDFrenderAsImages
(StringReader isr, URL base, int width, int height) renderAsImages
(URL url, int width, int height) converts URL to image object(s)final void
Reset all styles added with PD4ML.addStyle()final void
setAuthorName
(String name) sets an author name for the documentvoid
lets PD4ML to reuse data, cached by another PD4ML instance.void
makes PD4ML to add a cookie with given name and value to each URL connection requestvoid
setDefaultTTFs
(String serif, String sansserif, String monospace) defines deafult TTF font faces to be used as substritutions for unknown fonts.final void
setDocumentTitle
(String title) forces to override HTML titlevoid
setDynamicParams
(Map dynamicParams) void
setHtmlWidth
(int width) defines desired HTML page width in screen pixels.void
setPageFooter
(PD4PageMark mark) defines page footer areavoid
setPageHeader
(PD4PageMark mark) defines page header areavoid
setPageInsets
(Insets ii) specifies page insets in pointsvoid
specifies page insets in millimeters.void
defines page size in points.void
defines page size in milimeters.void
setPermissions
(String password, int permissions, boolean isStrong) forces the resulting document to be encrypted with the given passwordvoid
setSessionID
(String sessionID) the method informs PD4ML about current session ID (in web application environments).static final int
translate
(int i) converts from millimeters to pointsvoid
useAdobeFontMetrics
(boolean use) Deprecated.always uses AFMvoid
useHttpRequest
(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) method allows to inform PD4ML about actual HTTP request context (if any).void
useServletContext
(jakarta.servlet.ServletContext ctx) method allows to inform PD4ML about actual servlet context (if any).void
enables TTF font embedding subsystem.
-
Field Details
-
ISO8859_1
- See Also:
-
FILE_ENCODING
- See Also:
-
adjustHtmlWidthFlag
public boolean adjustHtmlWidthFlag -
fitPageVertically
public boolean fitPageVertically -
fitPageVerticallyAndCenter
public boolean fitPageVerticallyAndCenter -
debug
public boolean debug -
disableHyperlinksFlag
public boolean disableHyperlinksFlag
-
-
Constructor Details
-
PD4ML
public PD4ML()PD4ML Constructor Creates and initializes an instance of the rendering engine
-
-
Method Details
-
isDemoMode
public static final boolean isDemoMode()returns true if the library is used in evaluation mode- Since:
- v1.1.0
-
isPro
public static final boolean isPro()returns true if it is Pro version of the library- Since:
- v3.8.1
-
getVersion
getVersion() returns current version number- Returns:
- version number formatted as a string
-
merge
Merges conversion result with an already existing PDF document- Parameters:
input
- PDF document input streamfromPage
- start page of the existing document (1 or greater)toPage
- end page of the existing document (-1 means all pages)append
- 'true' forces to append the existing PDF to the conversion result. Otherwise the existing document will lead the conversion result.- Since:
- v3.8 *Pro*
-
merge
Merges conversion result with an already existing PDF document- Parameters:
input
- PDF document readerfromPage
- start page of the existing document (1 or greater)toPage
- end page of the existing document (-1 means all pages)append
- 'true' forces to append the existing PDF to the conversion result. Otherwise the existing document will lead the conversion result.- Since:
- v3.8 *Pro*
-
render
public void render(InputStreamReader isr, OutputStream os) throws InvalidParameterException, IOException converts input data to PDF- Parameters:
isr
- input stream reader of formatted data. Relies to properly specified encoding.os
- output stream to generate PDF to- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
converts input data to PDF- Parameters:
isr
- string reader of formatted data. Relies to properly specified encoding.os
- output stream to generate PDF to- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
public void render(InputStreamReader isr, OutputStream os, URL base) throws InvalidParameterException, IOException converts input data to PDF.- Parameters:
isr
- input stream reader of formatted data. Relies to properly specified encoding.os
- output stream to generate PDF tobase
- base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
public void render(StringReader isr, OutputStream os, URL base, String encoding) throws InvalidParameterException, IOException converts input data to PDF- Parameters:
isr
- string reader of formatted data. Take care for proper encodingos
- output stream to generate PDF tobase
- base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tagencoding
- content encoding- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
public void render(StringReader isr, OutputStream os, URL base) throws InvalidParameterException, IOException converts input data to PDF- Parameters:
isr
- string reader of formatted data. Take care for proper encodingos
- output stream to generate PDF tobase
- base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
public void render(StringReader[] isrs, OutputStream os, URL base) throws InvalidParameterException, IOException converts input data to PDF- Parameters:
isrs
- array of string readers wrap formatted data. Take care for proper encodingos
- output stream to generate PDF tobase
- base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag- Throws:
InvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
public void render(String textUrl, OutputStream os) throws MalformedURLException, InvalidParameterException, IOException input data referred by URL to PDF- Parameters:
textUrl
- text representation of the input data URLos
- output stream to generate PDF to- Throws:
MalformedURLException
- invalid URLInvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
converts input data referred by URL to PDF- Parameters:
url
- input data URLos
- output stream to generate PDF to- Throws:
MalformedURLException
- invalid URLInvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
render
converts input data referred by URLs to PDF- Parameters:
urls
- input data URLsos
- output stream to generate PDF to- Throws:
MalformedURLException
- invalid URLInvalidParameterException
- the input or output stream is nullIOException
- input/output problems
-
enableDebugInfo
public void enableDebugInfo()enables an output of debug messages. (absolute paths to loaded images and TTF)- Since:
- v1.2.0
-
useTTF
enables TTF font embedding subsystem. Available only in professional version of PD4ML.- Parameters:
embed
- if true forces PD4ML to include used font glyphs to the resulting PDFpathToFontDirs
- URL of a font directory.The font directory should contain pd4fonts.properties mapping file. The file records have the following format:
In order to support J2EE deployments a PD4ML-specific protocol "java:" is supported to load font resources via ClassLoader.
font_name=file_name
- font_name - font name used in the source HTML.
- file_name - font file name (should exist in the font directory)
Example:
Book\ Antiqua=BKANT.TTF
To generate the file automatically you may use the command line call:
java -jar pd4ml.jar -configure.fonts <fontdir>
After the generation, please edit the file and remove manually all references to the fonts, that are not allowed to be redistributed. Contact your TTF fonts provider for the info.Example: useTTF( "java:myfonts", true );
In that case the runtime looks for a fonts folder named "/myfonts" in all JAR files available for the application class loaders. The content of the folder should correspond to the rules described above: pd4fonts.properties + *.ttf
Example: useTTF( "java:", true );
The simpliest case. The runtime looks for a JAR file which contains pd4fonts.properties + *.ttf in the root directory.
- Throws:
FileNotFoundException
- if pd4fonts.properties file is not found or the file refers to missing font files
-
generatePdfForms
forces PD4ML to convert HTML forms into PDF forms (Acroforms). Note: The feature is at a very early stage now (v3.2.3).- Parameters:
useTtfFont
- (not implemented yet) - UNICODE TTF font name to be used for form input. The name must appear in pd4fonts.propertiesenable
- enables or disables the feature- Since:
- v3.2.3 Pro
- See Also:
-
generateMulticolumn
public void generateMulticolumn(int columns, int span, boolean millimeters) switches PD4ML into multicolumn mode. The mode in not compatible with adjustHtmlWidth() and fitPageVertically() calls.- Parameters:
columns
- - number of columns per pagespan
- - space between the columnsmillimeters
- - if 'true' the gap is in millimeters, otherwise in points
-
useServletContext
public void useServletContext(jakarta.servlet.ServletContext ctx) method allows to inform PD4ML about actual servlet context (if any). An access to servlet context allows to resolve absolute resource paths.- Parameters:
ctx
- servlet context
-
useHttpRequest
public void useHttpRequest(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) method allows to inform PD4ML about actual HTTP request context (if any). HTTP request/response allows to get output of dynamic webapp resources.- Parameters:
httpRequest
- actual HTTP requesthttpResponse
- actual HTTP response
-
setDefaultTTFs
defines deafult TTF font faces to be used as substritutions for unknown fonts.- Parameters:
serif
- - plain font face for serif fonts (like Times New Roman)sansserif
- - plain font face for sansserif fonts (like Helvetica or Arial)monospace
- - plain font face for monospace fonts (like Courier New)- Since:
- 3.0.2
-
enableRenderingPatch
public void enableRenderingPatch(boolean patch) Deprecated.no patching is neededenables or disables a patch of the Swing HTML rendering engine. The patch solves some visual problems with unknown tags and corrupted representation of XHTML files. By default the patch is enabled.- Parameters:
patch
- boolean switch
-
useAdobeFontMetrics
public void useAdobeFontMetrics(boolean use) Deprecated.always uses AFMif set to true, it forces PD4ML to use Adobe font glyph widths instead of the font metrics provided by Java graphical environment. As a result HTML page layout can look broken in GUI (in PD4ML Browser/Converter; for instance, text strings can overlap each other), but resulting PDF is rendered usually more correctly.- Parameters:
use
- boolean switch- Since:
- v1.1.0
-
generateOutlines
public void generateOutlines(boolean fromHeadings) if triggered, than PD4ML generates PDF bookmarks (aka outlines).- Parameters:
fromHeadings
- if set to false, PD4ML creates PDF bookmarks taken from <a name="destination">Label</a> tags. If a label is not defined, it uses destination string as visible label.
if set to true, than PD4ML creates PDF bookmark tree structure derived from <H1>-<H6> structure.- Since:
- v1.2.0
-
setSessionID
the method informs PD4ML about current session ID (in web application environments). The session ID is implicitely added by PD4ML to resource references (CSS, image etc). The addition is done in the following form: "resource.jpg;jsessionid=<sessionID>?other_args". "jsessionid" reserved name can be overriden by a setting of "pd4ml.sessionid.varname" environment variable- Parameters:
sessionID
- actual session ID- Since:
- v3.0.0.b1
-
overrideDocumentEncoding
sets default encoding for URL-addressed HTML documents- Parameters:
encoding
- name- Since:
- v3.7.1
-
disableHyperlinks
public void disableHyperlinks()if triggered, PD4ML does not generate active hyperlinks in resulting PDF.- Since:
- v1.2.0
-
enableImgSplit
public void enableImgSplit(boolean split) allows to disable image splitting by page breaks. By default the option is true (splitting enabled). If the option is set to false, than PD4ML tries to put page breaks protecting the images. If an image height (in screen pixels) is bigger than computed page height (in screen pixels), than it will be splitted regardless the option.- Parameters:
split
- boolean switch- See Also:
-
enableTableBreaks
public void enableTableBreaks(boolean enable) Deprecated.UseenableSmartTableBreaks(boolean)
instead- Since:
- v2.2.0b1/1.2.6/3.1.0
-
enableSmartTableBreaks
public void enableSmartTableBreaks(boolean enable) The method switches on/off the experimental table break feature. If it set to true, PD4ML tries to insert page breaks inbetween table rows to make the table portions fit PDF page height. If the table has a header (the first row with <th> cells only) it replicates the row to each table section. In order avoid multi-pass re-layouting of source HTML, the feature is implemented by simple way and has its limitations: it does not support nested tables, multi-page rowspans etc. As long as the feature experimental please use it in production only with extensively tested HTML templates.- Since:
- v3.6.1b2
-
setPageHeader
defines page header area- Parameters:
mark
- header configuration object- Throws:
InvalidParameterException
- when the config is null- Since:
- v1.0.5
-
setPageSizeMM
defines page size in milimeters. The method internally converts sizes to points and calls setPageSize()- Parameters:
d
- page dimensions in mm- Throws:
InvalidParameterException
- See Also:
-
setPermissions
forces the resulting document to be encrypted with the given password- Parameters:
password
- password. If is set to "empty", than no password assigned to document, only permissions.permissions
- an integer value according to PDF encryption specificationisStrong
- selects between two type of PDF encryption: type2 (false) and type3 (true)- Since:
- v1.1.0
-
setCookie
makes PD4ML to add a cookie with given name and value to each URL connection request- Parameters:
name
- namevalue
- value- Since:
- v3.0.2
-
addDocumentActionHandler
method defines JavaScript action handler for generated document.- Parameters:
actionType
- "OpenAction", "DC" (document close), "WS" (will save), "DS" (did save), "WP" (will print) or "DP" (did print)javaScript
- handler code
-
setPageSize
defines page size in points. A set of predefined page format constants is available in the PD4Constants interface.
To get "Landscape" page orientation of of the constant page sizes use changePageOrientation() method call to landscape convert the- Parameters:
d
- page dimensions in points- Throws:
InvalidParameterException
- See Also:
-
setPageInsetsMM
specifies page insets in millimeters. The method internally converts sizes to points and calls setPageInsets()- Parameters:
ii
- page insets in millimeters- Throws:
InvalidParameterException
- See Also:
-
setPageInsets
specifies page insets in points- Parameters:
ii
- page insets in points- Throws:
InvalidParameterException
-
setHtmlWidth
defines desired HTML page width in screen pixels. Virtually it can be seen as a web browser window horizonltal resize.
In the resulting PDF the HTML width is mapped to the paper page width (minus insets). There is no way to specify HTML page height. The height in screen pixels is set automatically depending on the width and the paper page proportions.- Parameters:
width
- HTML width in screen pixels- Throws:
InvalidParameterException
- when the width is not a positive value great that 0.
-
adjustHtmlWidth
public void adjustHtmlWidth()sets htmlWidth to the most right margin of the HTML block content. Calling the method would force PD4ML to build HTML layout with htmlWidth set by setHtmlWidth(int), to determine the most right edge of rendered content and to use the value for PDF mapping. Notes:- The method takes no effect for multi-URL PD4ML call: render(URL[],OutputStream)
- In order to use the method efficiently, it is important to call setHtmlWidth(int) with a parameter value, which is greater than the expected right edge offset.
- If the source document has HTML objects, whose width is set to 100%, than the method call is meaningless.
- As long as htmlWidth affects HTML-to-PDF scale factor, usage of the method causes inconstancy of font/object sizes in the resulting PDF from document to document.
- Since:
- 3.0.2
-
fitPageVertically
public void fitPageVertically()forces PD4ML to downscale entire HTML layout to fit a single PDF page vertically.- Since:
- v3.0.4
-
fitPageVertically
public void fitPageVertically(boolean center) -
generatePdfa
public final void generatePdfa(boolean enable) Forces PD4ML to output PDF compliant with PDF/A specification. PDF/A specification requires all used fonts to be embedded to the resulting document. So the method call cannot guarantee the resulting doc is PDF/A, for example, if TTF embedding is disabled or not configured. To make sure a resulting document matches PDF/A requirements, request the last rendering status.- Since:
- v3.6.0
- See Also:
-
protectPhysicalUnitDimensions
public void protectPhysicalUnitDimensions()makes PD4ML to output PDF objects respecting dimensions/font sizes given in "in", "pt", "cm" etc. Use the method carefully: as long as it triggered, there is no single HTML-to-PDF scale factor for all HTML objects. The resulting PDF layout may appear visually corrupted. If the method is not triggered, all sizes given in physical measurement units are converted to their screen pixel equivalents (using 72dpi) before HTML layouting. The method call can not be combined with adjustHtmlWidth() and fitPageVertically() calls, which affect HTML-to-PDF scale factor their own way.- Since:
- v3.0.4
-
interpolateImages
public final void interpolateImages(boolean mode) enables or disables image interpolation- Parameters:
mode
- true - enables interpolation. default is false- Since:
- v1.0.5
-
setAuthorName
sets an author name for the document- Parameters:
name
- author's name- Since:
- v1.0.5
-
setDocumentTitle
forces to override HTML title- Parameters:
title
- document title- Since:
- v1.0.5
-
addStyle
public final void addStyle(URL stylesheet, boolean overrideDocumentStyles) throws InvalidParameterException Apply additional stylesheet to the document- Parameters:
stylesheet
- of css stylesheetoverrideDocumentStyles
- if true, applies the stylesheet after styles defined in the document header.- Throws:
InvalidParameterException
- too many styles added- Since:
- v3.1.0 Pro
-
addStyle
public final void addStyle(String stylesheet, boolean overrideDocumentStyles) throws InvalidParameterException Apply additional stylesheet to the document- Parameters:
stylesheet
- stylesheet contentoverrideDocumentStyles
- if true, applies the stylesheet after styles defined in the document header.- Throws:
InvalidParameterException
- too many styles added- Since:
- v3.1.0 Pro
-
resetAddedStyles
public final void resetAddedStyles()Reset all styles added with PD4ML.addStyle()- Since:
- v3.1.0 Pro
-
inlineHtmlHeaderHeight
protected int inlineHtmlHeaderHeight(PageHeaderElement header, String title, int pageNumber, Map data, int maxHeight, int htmlWidth, int generation) Measures height of header or footer (defined inline).- Parameters:
header
- header elementtitle
- document title (cab be overriden by API)pageNumber
- current page numberdata
- dynamic data for placeholders substitutionmaxHeight
- height limithtmlWidth
- actualsetHtmlWidth(int)
parametergeneration
- dynamic data generation id- Returns:
- header/footer area height
-
printBackground
protected void printBackground(PD4Device gd, PD4PageMark header, PD4PageMark footer, URL base, int pageNumber, ResourceCache cache) throws IOException - Throws:
IOException
-
renderAsImages
converts URL to image object(s)- Parameters:
width
- target image widthheight
- target image height- Returns:
- an array of buffered images, represent a page.
- Throws:
IOException
-
renderAsImages
public BufferedImage[] renderAsImages(StringReader isr, URL base, int width, int height) throws IOException - Parameters:
isr
- string reader of formatted data. Take care for proper encodingbase
- base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tagwidth
- target image widthheight
- target image height- Returns:
- an array of buffered images, represent a page.
- Throws:
IOException
-
debug
debug() utility method- Parameters:
str
- debug message
-
translate
public static final int translate(int i) converts from millimeters to points- Parameters:
i
- value in millimeters
-
changePageOrientation
rotates given page format by 90 degrees.
Make sure that after rotating of standard page formats from PD4Constants you pass the new dimensions to setPageSize() (not setPageSizeMM())- Parameters:
d
- original page dimension- Returns:
- modified page dimensions
-
predictScale
-
predictPageHeight
-
setDynamicParams
- Parameters:
dynamicParams
- a set of key/value (String/String) pairs to dynamically substitute placeholders in HTML template (like "$[key]"). Key names "page", "total" and "title" are reserved for PDF headers and footers.
-
getLastRenderInfo
returns statistics for the last render() call- Parameters:
key
- - one of the currently supported keys: "pd4ml.document.height.px", "pd4ml.right.edge.px" or "pd4ml.total.pages".- Returns:
- Long object (for the currently implemented keys; other types expected in the future)
- Since:
- 3.5.1
- See Also:
-
outputRange
- Parameters:
description
- a string with output rules. Currently allows to limit a scope of generated pages. Examples: "2+" - skip the first page, "1-2" - output only the first and the second pages, "even" or "odd" - it is obvious. The rules may be combined: "3-7,odd"- Since:
- v3.5.5
-
outputFormat
- Parameters:
format
- file format to output. PD4Constants.PDF - default.- Since:
- v3.7.0
-
outputFormat
- Parameters:
format
- file format to output. PD4Constants.PDF - default.height
- - limits resulting document simentions by height. relevant for HTML-to-image conversions onlywidth
- - limits resulting document simentions by width. relevant for HTML-to-image conversions only- Since:
- v3.7.1
-
addMetadata
The method defines custom properties for PDF document meta data. The method takes effect only in PD4ML Volume DMS and PD4ML SRC license binaries.- Parameters:
key
- a unique name, which must not be one of the standard property names Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate and Trappedvalue
- data itselfhide
- makes the metadata not appear in the PDF document properties dialog of Acroread
-
clearCache
public void clearCache()removes all objects (images, CSS, etc) from internal caches.- Since:
- v3.6.0fx1
-
getCache
- Returns:
- wrapped PD4ML cache to be reused
- Since:
- v3.6.1b2
- See Also:
-
setCache
lets PD4ML to reuse data, cached by another PD4ML instance. PD4ML caches data in static hash tables, which implicitly share the cached data amonth PD4ML instances. The method call makes only sence if the tables are garbage collected for some reasons.- Since:
- v3.6.1b2
- See Also:
-
monitorProgress
conversion progress callback support- Parameters:
listener
- receiver of progress update messages
-