org.zefer.pd4ml
Class PD4ML

java.lang.Object
  extended by org.zefer.pd4ml.PD4Constants
      extended by org.zefer.pd4ml.PD4ML

public class PD4ML
extends PD4Constants


Nested Class Summary
static class PD4ML.StatusMessage
           
 
Field Summary
 boolean adjustHtmlWidthFlag
           
 boolean debug
           
 boolean disableHyperlinksFlag
           
static java.lang.String FILE_ENCODING
           
 boolean fitPageVertically
           
static java.lang.String ISO8859_1
           
 
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_ENABLE_CANVAS_INTERPRETER, PD4ML_ENABLE_HTTP_ERRORS, PD4ML_EXTERNAL_CANVAS_HANDLER, PD4ML_EXTRA_RESOURCE_LOADERS, PD4ML_FAKE_BROWSER, PD4ML_FIX20130116, 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_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_STYLESHEETS_TO_OMIT, PD4ML_TOTAL_PAGES, PDF, PDFA, PNG24, PNG8, RTF, RTF_WMF, TABLOID, TIFF, TIFF_COMPRESSED, TRANSLATE_FACTOR
 
Constructor Summary
PD4ML()
          PD4ML Constructor Creates and initializes an instance of the rendering engine
 
Method Summary
 void addDocumentActionHandler(java.lang.String actionType, java.lang.String javaScript)
          method defines JavaScript action handler for generated document.
 void addMetadata(java.lang.String key, java.lang.String value, boolean hide)
          The method defines custom properties for PDF document meta data.
 void addStyle(java.lang.String stylesheet, boolean overrideDocumentStyles)
          Apply additional stylesheet to the document
 void addStyle(java.net.URL stylesheet, boolean overrideDocumentStyles)
          Apply additional stylesheet to the document
 void adjustHtmlWidth()
          sets htmlWidth to the most right margin of the HTML block content.
 java.awt.Dimension changePageOrientation(java.awt.Dimension d)
          rotates given page format by 90 degrees.
 void clearCache()
          removes all objects (images, CSS, etc) from internal caches.
static void debug(java.lang.String str)
          debug() utility method
 void disableHyperlinks()
          if triggered, PD4ML does not generate active hyperlinks in resulting PDF.
 void enableDebugInfo()
          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 needed
 void enableSmartTableBreaks(boolean enable)
          The method switches on/off the experimental table break feature.
 void enableTableBreaks(boolean enable)
          Deprecated.  
 void fitPageVertically()
          forces PD4ML to downscale entire HTML layout to fit a single PDF page vertically.
 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).
 void generatePdfa(boolean enable)
          Forces PD4ML to output PDF compliant with PDF/A specification.
 void generatePdfForms(boolean enable, java.lang.String useTtfFont)
          forces PD4ML to convert HTML forms into PDF forms (Acroforms).
 PD4Cache getCache()
           
 java.lang.Object getLastRenderInfo(java.lang.String key)
          returns statistics for the last render() call
static java.lang.String getVersion()
          getVersion() returns current version number
protected  int inlineHtmlHeaderHeight(PageHeaderElement header, java.lang.String title, int pageNumber, java.util.Map data, int maxHeight, int htmlWidth, int generation)
          Measures height of header or footer (defined inline).
 void interpolateImages(boolean mode)
          enables or disables image interpolation
static boolean isDemoMode()
          returns true if the library is used in evaluation mode
static boolean isPro()
          returns true if it is Pro version of the library
 void merge(java.io.InputStream input, int fromPage, int toPage, boolean append)
          Merges conversion result with an already existing PDF document
 void merge(java.io.Reader input, int fromPage, int toPage, boolean append)
          Merges conversion result with an already existing PDF document
 void monitorProgress(PD4ProgressListener listener)
          conversion progress callback support
 void outputFormat(java.lang.String format)
           
 void outputFormat(java.lang.String format, int width, int height)
           
 void outputRange(java.lang.String description)
           
 void overrideDocumentEncoding(java.lang.String encoding)
          sets default encoding for URL-addressed HTML documents
static int predictPageHeight(java.awt.Insets pageInsets, java.awt.Dimension pageSize, int userSpace)
           
static float predictScale(java.awt.Insets pageInsets, java.awt.Dimension pageSize, int userSpace)
           
protected  void printBackground(PD4Device gd, PD4PageMark header, PD4PageMark footer, java.net.URL base, int pageNumber, ResourceCache cache)
           
protected  void printHtmlHeaderAndFooter(PD4Device gd, PD4PageMark header, PD4PageMark footer, java.lang.String title, java.net.URL base, int userSpaceWidth, int totalPages, int pageNumber, java.lang.String encoding, ResourceCache cache, double scaleFactor)
           
protected  void printInlineHtmlHeaderOrFooter(PD4Device gd, boolean isFooter, PageHeaderElement inlineHeader, java.lang.String title, int totalPages, int pageNumber, java.util.Map data, int maxHeight, int htmlWidth, int generation, java.util.Vector footnotes)
          Prints header or footer (defined inline) whose height can vary from page to page.
protected  void printInlineRtfHeaderOrFooter(PD4RtfDevice gd, PageHeaderElement inlineHeader, java.lang.String title, java.util.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, java.lang.String title, java.net.URL base, int userSpaceWidth, java.lang.String encoding, ResourceCache cache, double scaleFactor, boolean firstPage)
           
 void protectPhysicalUnitDimensions()
          makes PD4ML to output PDF objects respecting dimensions/font sizes given in "in", "pt", "cm" etc.
 void render(java.io.InputStreamReader isr, java.io.OutputStream os)
          converts input data to PDF
 void render(java.io.InputStreamReader isr, java.io.OutputStream os, java.net.URL base)
          converts input data to PDF.
 void render(java.lang.String textUrl, java.io.OutputStream os)
          input data referred by URL to PDF
 void render(java.io.StringReader[] isrs, java.io.OutputStream os, java.net.URL base)
          converts input data to PDF
 void render(java.io.StringReader isr, java.io.OutputStream os)
          converts input data to PDF
 void render(java.io.StringReader isr, java.io.OutputStream os, java.net.URL base)
          converts input data to PDF
 void render(java.io.StringReader isr, java.io.OutputStream os, java.net.URL base, java.lang.String encoding)
          converts input data to PDF
 void render(java.net.URL[] urls, java.io.OutputStream os)
          converts input data referred by URLs to PDF
 void render(java.net.URL url, java.io.OutputStream os)
          converts input data referred by URL to PDF
 java.awt.image.BufferedImage[] renderAsImages(java.io.StringReader isr, java.net.URL base, int width, int height)
           
 java.awt.image.BufferedImage[] renderAsImages(java.net.URL url, int width, int height)
          converts URL to image object(s)
 void resetAddedStyles()
          Reset all styles added with PD4ML.addStyle()
 void setAuthorName(java.lang.String name)
          sets an author name for the document
 void setCache(PD4Cache cacheWrapper)
          lets PD4ML to reuse data, cached by another PD4ML instance.
 void setCookie(java.lang.String name, java.lang.String value)
          makes PD4ML to add a cookie with given name and value to each URL connection request
 void setDefaultTTFs(java.lang.String serif, java.lang.String sansserif, java.lang.String monospace)
          defines deafult TTF font faces to be used as substritutions for unknown fonts.
 void setDocumentTitle(java.lang.String title)
          forces to override HTML title
 void setDynamicParams(java.util.Map dynamicParams)
           
 void setHtmlWidth(int width)
          defines desired HTML page width in screen pixels.
 void setPageFooter(PD4PageMark mark)
          defines page footer area
 void setPageHeader(PD4PageMark mark)
          defines page header area
 void setPageInsets(java.awt.Insets ii)
          specifies page insets in points
 void setPageInsetsMM(java.awt.Insets ii)
          specifies page insets in millimeters.
 void setPageSize(java.awt.Dimension d)
          defines page size in points.
 void setPageSizeMM(java.awt.Dimension d)
          defines page size in milimeters.
 void setPermissions(java.lang.String password, int permissions, boolean isStrong)
          forces the resulting document to be encrypted with the given password
 void setSessionID(java.lang.String sessionID)
          the method informs PD4ML about current session ID (in web application environments).
static int translate(int i)
          converts from millimeters to points
 void useAdobeFontMetrics(boolean use)
          Deprecated. always uses AFM
 void useHttpRequest(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
          method allows to inform PD4ML about actual HTTP request context (if any).
 void useServletContext(ServletContext ctx)
          method allows to inform PD4ML about actual servlet context (if any).
 void useTTF(java.lang.String pathToFontDirs, boolean embed)
          enables TTF font embedding subsystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ISO8859_1

public static final java.lang.String ISO8859_1
See Also:
Constant Field Values

FILE_ENCODING

public static final java.lang.String FILE_ENCODING
See Also:
Constant Field Values

adjustHtmlWidthFlag

public boolean adjustHtmlWidthFlag

fitPageVertically

public boolean fitPageVertically

debug

public boolean debug

disableHyperlinksFlag

public boolean disableHyperlinksFlag
Constructor Detail

PD4ML

public PD4ML()
PD4ML Constructor Creates and initializes an instance of the rendering engine

Method Detail

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

public static java.lang.String getVersion()
getVersion() returns current version number

Returns:
version number formatted as a string

merge

public void merge(java.io.InputStream input,
                  int fromPage,
                  int toPage,
                  boolean append)
Merges conversion result with an already existing PDF document

Parameters:
input - PDF document input stream
fromPage - 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

public void merge(java.io.Reader input,
                  int fromPage,
                  int toPage,
                  boolean append)
Merges conversion result with an already existing PDF document

Parameters:
input - PDF document reader
fromPage - 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(java.io.InputStreamReader isr,
                   java.io.OutputStream os)
            throws java.security.InvalidParameterException,
                   java.io.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:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.io.StringReader isr,
                   java.io.OutputStream os)
            throws java.security.InvalidParameterException,
                   java.io.IOException
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:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.io.InputStreamReader isr,
                   java.io.OutputStream os,
                   java.net.URL base)
            throws java.security.InvalidParameterException,
                   java.io.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
base - base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag
Throws:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.io.StringReader isr,
                   java.io.OutputStream os,
                   java.net.URL base,
                   java.lang.String encoding)
            throws java.security.InvalidParameterException,
                   java.io.IOException
converts input data to PDF

Parameters:
isr - string reader of formatted data. Take care for proper encoding
os - output stream to generate PDF to
base - base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag
encoding - content encoding
Throws:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.io.StringReader isr,
                   java.io.OutputStream os,
                   java.net.URL base)
            throws java.security.InvalidParameterException,
                   java.io.IOException
converts input data to PDF

Parameters:
isr - string reader of formatted data. Take care for proper encoding
os - output stream to generate PDF to
base - base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag
Throws:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.io.StringReader[] isrs,
                   java.io.OutputStream os,
                   java.net.URL base)
            throws java.security.InvalidParameterException,
                   java.io.IOException
converts input data to PDF

Parameters:
isrs - array of string readers wrap formatted data. Take care for proper encoding
os - output stream to generate PDF to
base - base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag
Throws:
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.lang.String textUrl,
                   java.io.OutputStream os)
            throws java.net.MalformedURLException,
                   java.security.InvalidParameterException,
                   java.io.IOException
input data referred by URL to PDF

Parameters:
textUrl - text representation of the input data URL
os - output stream to generate PDF to
Throws:
java.net.MalformedURLException - invalid URL
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.net.URL url,
                   java.io.OutputStream os)
            throws java.security.InvalidParameterException,
                   java.io.IOException
converts input data referred by URL to PDF

Parameters:
url - input data URL
os - output stream to generate PDF to
Throws:
java.net.MalformedURLException - invalid URL
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - input/output problems

render

public void render(java.net.URL[] urls,
                   java.io.OutputStream os)
            throws java.security.InvalidParameterException,
                   java.io.IOException
converts input data referred by URLs to PDF

Parameters:
urls - input data URLs
os - output stream to generate PDF to
Throws:
java.net.MalformedURLException - invalid URL
java.security.InvalidParameterException - the input or output stream is null
java.io.IOException - 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

public void useTTF(java.lang.String pathToFontDirs,
                   boolean embed)
            throws java.io.FileNotFoundException
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 PDF
pathToFontDirs - URL of a font directory.
The font directory should contain pd4fonts.properties mapping file. The file records have the following format:
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.

In order to support J2EE deployments a PD4ML-specific protocol "java:" is supported to load font resources via ClassLoader.

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:
java.io.FileNotFoundException - if pd4fonts.properties file is not found or the file refers to missing font files

generatePdfForms

public void generatePdfForms(boolean enable,
                             java.lang.String useTtfFont)
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.properties
enable - enables or disables the feature
Since:
v3.2.3 Pro
See Also:
useTTF(String, boolean)

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 page
span - - space between the columns
millimeters - - if 'true' the gap is in millimeters, otherwise in points

useServletContext

public void useServletContext(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(HttpServletRequest httpRequest,
                           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 request
httpResponse - actual HTTP response

setDefaultTTFs

public void setDefaultTTFs(java.lang.String serif,
                           java.lang.String sansserif,
                           java.lang.String monospace)
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 needed

enables 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 AFM

if 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

public void setSessionID(java.lang.String sessionID)
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

public void overrideDocumentEncoding(java.lang.String encoding)
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:
setHtmlWidth(int)

enableTableBreaks

public void enableTableBreaks(boolean enable)
Deprecated. 

Use enableSmartTableBreaks(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

public void setPageHeader(PD4PageMark mark)
                   throws java.security.InvalidParameterException
defines page header area

Parameters:
mark - header configuration object
Throws:
java.security.InvalidParameterException - when the config is null
Since:
v1.0.5

setPageFooter

public void setPageFooter(PD4PageMark mark)
                   throws java.security.InvalidParameterException
defines page footer area

Parameters:
mark - footer configuration object
Throws:
java.security.InvalidParameterException - when the config is null or contains invalid data
Since:
v1.0.5

setPageSizeMM

public void setPageSizeMM(java.awt.Dimension d)
                   throws java.security.InvalidParameterException
defines page size in milimeters. The method internally converts sizes to points and calls setPageSize()

Parameters:
d - page dimensions in mm
Throws:
InvalidParameterException, - when the specified page format is null or does not fit to already defined page insets
java.security.InvalidParameterException
See Also:
setPageSize(Dimension)

setPermissions

public void setPermissions(java.lang.String password,
                           int permissions,
                           boolean isStrong)
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 specification
isStrong - selects between two type of PDF encryption: type2 (false) and type3 (true)
Since:
v1.1.0

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value)
makes PD4ML to add a cookie with given name and value to each URL connection request

Parameters:
name - name
value - value
Since:
v3.0.2

addDocumentActionHandler

public void addDocumentActionHandler(java.lang.String actionType,
                                     java.lang.String javaScript)
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

public void setPageSize(java.awt.Dimension d)
                 throws java.security.InvalidParameterException
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, - when the specified page format is null or does not fit to already defined page insets
java.security.InvalidParameterException
See Also:
changePageOrientation(Dimension)

setPageInsetsMM

public void setPageInsetsMM(java.awt.Insets ii)
                     throws java.security.InvalidParameterException
specifies page insets in millimeters. The method internally converts sizes to points and calls setPageInsets()

Parameters:
ii - page insets in millimeters
Throws:
InvalidParameterException, - when the specified page insets object is null or when it does not fit to already defined page size
java.security.InvalidParameterException
See Also:
setPageInsets(Insets)

setPageInsets

public void setPageInsets(java.awt.Insets ii)
                   throws java.security.InvalidParameterException
specifies page insets in points

Parameters:
ii - page insets in points
Throws:
InvalidParameterException, - when the specified page insets object is null or when it does not fit to already defined page size
java.security.InvalidParameterException

setHtmlWidth

public void setHtmlWidth(int width)
                  throws java.security.InvalidParameterException
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:
java.security.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:

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

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:
PD4Constants.PD4ML_PDFA_STATUS, getLastRenderInfo(String)

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

public final void setAuthorName(java.lang.String name)
sets an author name for the document

Parameters:
name - author's name
Since:
v1.0.5

setDocumentTitle

public final void setDocumentTitle(java.lang.String title)
forces to override HTML title

Parameters:
title - document title
Since:
v1.0.5

addStyle

public final void addStyle(java.net.URL stylesheet,
                           boolean overrideDocumentStyles)
                    throws java.security.InvalidParameterException
Apply additional stylesheet to the document

Parameters:
stylesheet - of css stylesheet
overrideDocumentStyles - if true, applies the stylesheet after styles defined in the document header.
Throws:
java.security.InvalidParameterException - too many styles added
Since:
v3.1.0 Pro

addStyle

public final void addStyle(java.lang.String stylesheet,
                           boolean overrideDocumentStyles)
                    throws java.security.InvalidParameterException
Apply additional stylesheet to the document

Parameters:
stylesheet - stylesheet content
overrideDocumentStyles - if true, applies the stylesheet after styles defined in the document header.
Throws:
java.security.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

printInlineRtfHeaderOrFooter

protected void printInlineRtfHeaderOrFooter(PD4RtfDevice gd,
                                            PageHeaderElement inlineHeader,
                                            java.lang.String title,
                                            java.util.Map data,
                                            int htmlWidth,
                                            int generation)
Prints header or footer (defined inline) whose height can vary from page to page.

Parameters:
gd - RTF device
inlineHeader - header element
title - document title (cab be overriden by API)
data - dynamic data for placeholders substitution
generation - dynamic data generation id

printRtfHeaderOrFooter

protected void printRtfHeaderOrFooter(PD4RtfDevice gd,
                                      PD4PageMark header,
                                      java.lang.String title,
                                      java.net.URL base,
                                      int userSpaceWidth,
                                      java.lang.String encoding,
                                      ResourceCache cache,
                                      double scaleFactor,
                                      boolean firstPage)

printInlineHtmlHeaderOrFooter

protected void printInlineHtmlHeaderOrFooter(PD4Device gd,
                                             boolean isFooter,
                                             PageHeaderElement inlineHeader,
                                             java.lang.String title,
                                             int totalPages,
                                             int pageNumber,
                                             java.util.Map data,
                                             int maxHeight,
                                             int htmlWidth,
                                             int generation,
                                             java.util.Vector footnotes)
Prints header or footer (defined inline) whose height can vary from page to page.

Parameters:
gd - device
isFooter - boolean mode: "header or footer"
inlineHeader - header element
title - document title (cab be overriden by API)
totalPages - total number of pages
pageNumber - current page number
data - dynamic data for placeholders substitution
maxHeight - height limit
htmlWidth - actual setHtmlWidth(int) parameter
generation - dynamic data generation id
footnotes - page footnotes (if any)

inlineHtmlHeaderHeight

protected int inlineHtmlHeaderHeight(PageHeaderElement header,
                                     java.lang.String title,
                                     int pageNumber,
                                     java.util.Map data,
                                     int maxHeight,
                                     int htmlWidth,
                                     int generation)
Measures height of header or footer (defined inline).

Parameters:
header - header element
title - document title (cab be overriden by API)
pageNumber - current page number
data - dynamic data for placeholders substitution
maxHeight - height limit
htmlWidth - actual setHtmlWidth(int) parameter
generation - dynamic data generation id
Returns:
header/footer area height

printBackground

protected void printBackground(PD4Device gd,
                               PD4PageMark header,
                               PD4PageMark footer,
                               java.net.URL base,
                               int pageNumber,
                               ResourceCache cache)

printHtmlHeaderAndFooter

protected void printHtmlHeaderAndFooter(PD4Device gd,
                                        PD4PageMark header,
                                        PD4PageMark footer,
                                        java.lang.String title,
                                        java.net.URL base,
                                        int userSpaceWidth,
                                        int totalPages,
                                        int pageNumber,
                                        java.lang.String encoding,
                                        ResourceCache cache,
                                        double scaleFactor)

renderAsImages

public java.awt.image.BufferedImage[] renderAsImages(java.net.URL url,
                                                     int width,
                                                     int height)
                                              throws java.io.IOException
converts URL to image object(s)

Parameters:
width - target image width
height - target image height
Returns:
an array of buffered images, represent a page.
Throws:
java.io.IOException

renderAsImages

public java.awt.image.BufferedImage[] renderAsImages(java.io.StringReader isr,
                                                     java.net.URL base,
                                                     int width,
                                                     int height)
                                              throws java.io.IOException
Parameters:
isr - string reader of formatted data. Take care for proper encoding
base - base URL to lookup referred resources like images or CSS. Can be specified in HTML body with <base href="..."> tag
width - target image width
height - target image height
Returns:
an array of buffered images, represent a page.
Throws:
java.io.IOException

debug

public static void debug(java.lang.String str)
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

public java.awt.Dimension changePageOrientation(java.awt.Dimension d)
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

public static final float predictScale(java.awt.Insets pageInsets,
                                       java.awt.Dimension pageSize,
                                       int userSpace)

predictPageHeight

public static final int predictPageHeight(java.awt.Insets pageInsets,
                                          java.awt.Dimension pageSize,
                                          int userSpace)

setDynamicParams

public void setDynamicParams(java.util.Map dynamicParams)
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

public java.lang.Object getLastRenderInfo(java.lang.String key)
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:
PD4Constants

outputRange

public void outputRange(java.lang.String description)
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

public void outputFormat(java.lang.String format)
Parameters:
format - file format to output. PD4Constants.PDF - default.
Since:
v3.7.0

outputFormat

public void outputFormat(java.lang.String format,
                         int width,
                         int height)
Parameters:
format - file format to output. PD4Constants.PDF - default.
height - - limits resulting document simentions by height. relevant for HTML-to-image conversions only
width - - limits resulting document simentions by width. relevant for HTML-to-image conversions only
Since:
v3.7.1

addMetadata

public void addMetadata(java.lang.String key,
                        java.lang.String value,
                        boolean hide)
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 Trapped
value - data itself
hide - 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

public PD4Cache getCache()
Returns:
wrapped PD4ML cache to be reused
Since:
v3.6.1b2
See Also:
setCache(PD4Cache)

setCache

public void setCache(PD4Cache cacheWrapper)
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:
getCache()

monitorProgress

public void monitorProgress(PD4ProgressListener listener)
conversion progress callback support

Parameters:
listener - receiver of progress update messages


Copyright © 2004-15 zefer.org. All Rights Reserved.