Forum Replies Created

Viewing 15 posts - 31 through 45 (of 4,217 total)
  • Author
  • in reply to: General questions / FAQ

    PD4ML provides 3 types of headers/footers.

    1. text-only
    2. html (PD4ML Pro)
    3. inline (PD4ML Pro)

    The first 2 options are available by PD4ML Java API calls (or as JSP custom tags mapped to PD4ML API): i.e.
    -> pd4ml.setPageFooter();

    1. Text only (in such form can be used only in JSP):
    Java version:
    [language=java:lsk60rtn]PD4PageMark footer = new PD4PageMark();
    footer.setPageNumberTemplate(“page $[page] of $[total]”);
    footer.setColor(new Color(0x008000));

    2. HTML formatted footer (in such form can be used only in JSP)

    [language=xml:lsk60rtn] page $[page] of $[total] [/language:lsk60rtn]
    Java version:
    [language=java:lsk60rtn]PD4PageMark footer = new PD4PageMark();
    footer.setHtmlTemplate(“page $[page] of $[total]“);

    areaHeight=”-1″ means “autocompute” there

    3. The third option, inline footer, allows to define footer body in HTML/PHP document:

    [language=xml:lsk60rtn] footer: $[page] of $[total] [/language:lsk60rtn]

    The definition impacts all subsequent pages after the page, where the footer defined. A new appearance of the footer overrides previously defined one.
    In order to define the footer for the first page, you need to place the definition immediately after tag or before .

    Also you may explicitly define pages, where the footer needs to be applied:

    [language=xml:lsk60rtn] first page footer: $[page] of $[total]
    footer: $[page] of $[total]

    The above defines different footers for the first page and for the rest of the pages (the second and others). Also “scope” understands “even”, “odd” and “skiplast” modifiers. Example:


    in reply to: PD4ML Tips & Tricks

    PDF viewers have a set of standard fonts like Times, Helvetica, Courier. It is guaranteeed, that PDFs with the fonts are shown correctly on any platform. It would be nice use them in full, but unfortunately there is no easy way to deal with the fonts metrics from Java. So for ISO-8859-1 charset we hardcoded the metrics tables into PD4ML, but for other characters (the rest of UNICODE space) it would be too bulky.

    In order to output characters, not belong to ISO-8859-1 charset, PD4ML requires you to configure and to use TTF embedding feature. The feature is available in PD4ML Pro only (

    The way TTF embedding is implemented by PD4ML may look overcomplicated at first glance. On practice it is not so; also there are reasons why TTF usage is not as transparent as in regular Java applications.

    In Java you may easily instantiate Font object for any font face name and to use it for text output. But for PDF generation PD4ML needs an access not only to java.awt.Font objects, but to the corresponding physical .ttf files (to parse them and to extract a subset of used glyphs). Unfortunately Java does not offer a way to locate TTF file for a particular java.awt.Font object.

    For that reason we introduced the font face -> font file mapping appraoch (with

    The needed actions are trivial:

    1. create fonts/ directory (i.e /path/to/my/fonts/) and copy needed TTFs into it.
    2. run generation command
      java -jar pd4ml.jar -configure.fonts /path/to/my/fonts/
      (as a result it should produce /path/to/my/fonts/
    3. reference /path/to/my/fonts/ directory from your Java/JSP/… code.

    If you want to avoid binding to a local directory, you may pack the fonts/ directory into a JAR, place it to classpath and access them via classloader. (~2MB) contains chinese_ttf sample, which illustrates how to do that.

    Very often there is no necessity to support multiple font faces, but missing of special characters (like δ, « …) or charsets (like Cyrillic, Arabic) support is critical.

    For the case we created a “quick hack” solution with easy-to-use TTF embedding.

    There is a JAR with 3 fonts for serif, sansserif and monospaced types (the fonts do not contain CJK glyphs): (~2MB)

    Add the JAR to application’s classpath (or put to WEB-INF/lib in webapp scenarios), address the fonts via Java classloader and specify, that the 3 fonts should be used as defaults:

    [language=java:34aepdr9]pd4ml.useTTF( “java:fonts”, true );
    pd4ml.setDefaultTTFs(“Times New Roman”, “Arial”, “Courier New”);[/language:34aepdr9]

    (Full Java API example:

    JSP equivalent:


    The same for the PHP wrapper (assuming that fonts.jar is in the same dir where pd4ml(_demo).jar is):

    [language=php:34aepdr9]passthru('java -Xmx512m -Djava.awt.headless=true -cp .:pd4ml_demo.jar:fonts.jar Pd4Php '' .
    $_POST['url'] . '' 800 A4 -ttf java:fonts 2>>stderr.txt');

    // Win32 version
    // passthru('java -Xmx512m -cp .;pd4ml_demo.jar;fonts.jar Pd4Cmd ' .
    // $_POST['url'] . ' 800 A4 -ttf fonts:jar');[/language:34aepdr9]

    in reply to: Troubleshooting

    [language=java:2zs7sz35]String _html = “”;
    ByteArrayInputStream htmlBin = null;
    OutputStream out = new ByteArrayOutputStream();
    PD4ML pd4ml = new PD4ML();
    pd4ml.setPageInsets(new Insets(10, 10, 10, 10));

    pd4ml.render(new StringReader(_html), out);[/language:2zs7sz35]
    The above block of code to generate pdf took more than 16 minutes in multi threaded environment. Can anybody help me to understand why it too longer time?

    This is started happening recently ….

    in reply to: HTML/CSS rendering issues

    I’m trying to user resolve_entities tag so Σ would translate to Sigma symbol, i have tried Σ and Σ everyone gives me question symbol (?)… how can i do it?

    in reply to: Prevent images being scaled

    As a rule images prepared for regular HTML documents have a resolution, which is not sufficient for print or for PDF. It is because print resolution typically ranges from 300dpi up to 1200dpi, while screen resolution is usually only 72dpi to 96dpi.

    PD4ML never resamples images, but embeds them “as is” (JPEGs and some species of PNG) or re-compress them non-lossy way to generic PDF image formar (GIFs and the rest of PNGs).

    A solution would be to use more detailed source images. For example:

    You’ll get better results if you add a hi-res image (let’s say 1000x1000px) to your doc with an image tag defines smaller dimensions 100 width=100>. It will be embedded to PDF with the all detailization of the original 1000x1000px image (good zoomable / good printable), but shrinked to 100×100. That would allow you to keep the original HTML layout not broken by the huge 1000×1000 image.

    Also we would recommend you to use JPEG image format (probably with the highest image quality settings) for such big images. JPEGs are embedded “as is” and it keeps the resulting PDFs compact. For example, GIF needs to be recompressed, which makes the resulting PDF to grow.


    First I would suspect network delays by loading of referenced resources: images, CSS etc.

    Try to switch debug mode of PD4ML on


    and analyze server’s console or log during the “16 minutes”. Does it make big pauses by resource load attempts?

    in reply to: Entities to PDF

    PD4ML by default supports Latin-1 (ISO-8859-1) character set. Sigma symbol does not belong to it, so you need to use TTF embedding feature of PD4ML Pro.

    See pd4ml-html-css-pdf-tips-tricks-f7/ttf-embedding-t42.html

    in reply to: Right margin overflow

    Could you please attach a minimalistic sample PDF to illustrate the problem.


    We removed the https reference from our html and looks OK now. But my concern here is PD4ML is looping and never terminating if any of the resource is not found (like img) or the connection delay is too long.

    in reply to: Prevent images being scaled

    Some more info about hi-res image printing:

    Note: PD4ML ignores print CSS media type and respects only stylesheets defined for all, screen and proprietary pdf media types.

    in reply to: Browser error "File does not begin with ‘%PDF-‘"

    I have this error (sometimes) when i use PD4ML with Tomcat 5.5.26 server.
    How can i fix it?


    in reply to: PD4ML Tips & Tricks


    Is there sample code to render multiple Notes documents (selected from a Notes view) to a single output pdf? Each Notes Document should be separated by a page break within the output pdf file.

    Any examples or pointers are greatly appreciated.


    in reply to: HTML/CSS rendering issues

    HI I’m trying to convert an HTML file to PDF using pd4ml 3.5 on MacOSX 10.4.11
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-275)

    We’re getting an exception and the file is not readable.

    The exception is:
    Exception in thread “main” java.lang.NullPointerException
    at org.zefer.html.doc.b.i.String(Unknown Source)
    at org.zefer.html.doc.x.o00000(Unknown Source)
    at org.zefer.html.doc.b.d.o00000(Unknown Source)
    at org.zefer.html.doc.x.o00000(Unknown Source)
    at org.zefer.html.doc.b.d.o00000(Unknown Source)
    at org.zefer.html.doc.x.o00000(Unknown Source)
    at org.zefer.html.doc.b.d.o00000(Unknown Source)
    at org.zefer.html.doc.x.o00000(Unknown Source)
    at org.zefer.html.doc.Document.paint(Unknown Source)
    at org.zefer.pd4ml.PD4ML.o00000(Unknown Source)
    at org.zefer.pd4ml.PD4ML.render(Unknown Source)
    at org.zefer.pd4ml.PD4ML.render(Unknown Source)
    at$PD4Converter.o00000(Unknown Source)
    at$PD4Converter.access$800(Unknown Source)
    at Source)

    We’ve checked the CSS and HTML but not sure what to look for.

    Any suggestions appreciated

    in reply to: NullPointerException in command line convert

    OK, more information…

    The problem is an img tag with style information.

    The website docs say img style, left and top are all supported (e.g. since v350)
    The trial 3.50 version I have has docs that say that left and top are not supported at all.

    Which is it?
    Is the trial download not the 3.5 version?
    If not, can we get a trial version which is?
    If it is, why isn’t this working?


    in reply to: NullPointerException in command line convert

    It is a bug in v350 code and it seems the actual development build v351 fixes the problem. I’ve just sent it to you by email to test on your side.

    A temporal v350 workaroung for the problem is to absolutely position not the image, but its enclosing DIV:



Viewing 15 posts - 31 through 45 (of 4,217 total)