org.zefer.pd4ml
Class PD4ML

java.lang.Object
  extended byorg.zefer.pd4ml.PD4ML
All Implemented Interfaces:
PD4Constants

public class PD4ML
extends java.lang.Object
implements PD4Constants


Field Summary
 
Fields inherited from interface org.zefer.pd4ml.PD4Constants
A0, A1, A10, A2, A3, A4, A5, A6, A7, A8, A9, AllowAssembly, AllowContentExtraction, AllowCopy, AllowDegradedPrint, AllowModify, AllowPrint, HALFLETTER, ISOB0, ISOB1, ISOB2, ISOB3, ISOB4, ISOB5, LEDGER, LEGAL, LETTER, NOTE, TABLOID, TRANSLATE_FACTOR
 
Constructor Summary
PD4ML()
          PD4ML Constructor Creates and initializes an instance of the rendering engine
 
Method Summary
 java.awt.Dimension changePageOrientation(java.awt.Dimension d)
          rotates given page format by 90 degrees.
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 or disables an output of debug messages.
 void enableImgSplit(boolean split)
          allows to disable image splitting by page breaks.
 void enableRenderingPatch(boolean patch)
          enables or disables a patch of the Swing HTML rendering engine.
 void enableTableBreaks(boolean enable)
          The method switches on/off the experimental table break feature.
 void generateOutlines(boolean fromHeadings)
          if triggered, than PD4ML generates PDF bookmarks (aka outlines).
static java.lang.String getVersion()
          getVersion() returns current version number
 void interpolateImages(boolean mode)
          enables or disables image interpolation
static boolean isDemoMode()
          returns true if the library is used in evaluation mode
protected  void profile(java.lang.String str)
          profile() utility method
 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 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 url, java.io.OutputStream os)
          converts input data referred by URL to PDF
 void setAuthorName(java.lang.String string)
          sets an author name for the document
 void setDocumentTitle(java.lang.String string)
          forces to override HTML title
 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
static int translate(int i)
          converts from millimeters to points
 void useAdobeFontMetrics(boolean use)
          if set to true, it forces PD4ML to use Adobe font glyph widths instead of the font metrics provided by Java graphical environment.
 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
 

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

getVersion

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

Returns:
version number formatted as a string

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.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

enableDebugInfo

public void enableDebugInfo()
enables or disables 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 (for the time being the option does not work, the glyphs are always included)
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

enableRenderingPatch

public void enableRenderingPatch(boolean patch)
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)
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

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)
The method switches on/off the experimental table break feature. If it set to true, PD4ML tries to split tables to smaller ones that fit page height. Note: the method forces multiple re-layouting of source HTML and requires extra resources for doing that. It is not recommended for bulky HTML documents.

Since:
v2.2.0b1/1.2.6

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

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.

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 string)
sets an author name for the document

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

setDocumentTitle

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

Parameters:
string - document title
Since:
v1.0.5

debug

public static void debug(java.lang.String str)
debug() utility method

Parameters:
str - debug message

profile

protected void profile(java.lang.String str)
profile() 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


Copyright © 2005 zefer.org. All Rights Reserved.