Forum Replies Created

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

    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):
    [language=xml:lsk60rtn][/language:lsk60rtn]
    Java version:
    [language=java:lsk60rtn]PD4PageMark footer = new PD4PageMark();
    footer.setPageNumberTemplate(“page $[page] of $[total]”);
    footer.setTitleAlignment(PD4PageMark.LEFT_ALIGN);
    footer.setPageNumberAlignment(PD4PageMark.RIGHT_ALIGN);
    footer.setColor(new Color(0x008000));
    footer.setInitialPageNumber(1);
    footer.setPagesToSkip(1);
    footer.setFontSize(14);
    footer.setAreaHeight(18);
    pd4ml.setPageFooter(footer);[/language:lsk60rtn]

    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]“);
    footer.setAreaHeight(-1);
    pd4ml.setPageFooter(footer);[/language:lsk60rtn]

    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]


    …[/language:lsk60rtn]
    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:

    scope=”2,5-10,even,skiplast”

    in reply to: PD4ML Tips & Tricks
    #26202

    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 (http://pd4ml.com/reference.htm#7.1)

    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 pd4fonts.properties).

    The needed actions are trivial:

    1. create fonts/ directory (i.e /path/to/my/fonts/) and copy needed TTFs into it.
    2. run pd4font.properties generation command
      java -jar pd4ml.jar -configure.fonts /path/to/my/fonts/
      (as a result it should produce /path/to/my/fonts/pd4font.properties)
    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.

    http://pd4ml.com/examples.zip (~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):

    http://pd4ml.com/i/easyfonts/fonts.jar (~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: http://pd4ml.com/i/easyfonts/EasyFonts.java)

    JSP equivalent:

    [language=xml:34aepdr9][/language:34aepdr9]

    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
    #26203

    [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.setHtmlWidth(950);
    pd4ml.setPageSize(PD4Constants.A4);

    pd4ml.enableTableBreaks(true);
    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
    #26204

    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
    #27257

    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.

    #27324

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

    Try to switch debug mode of PD4ML on

    [language=java:2m30k7jo]pd4ml.enableDebugInfo()[/language:2m30k7jo]

    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
    #27328

    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
    #27252

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

    #27326

    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
    #27256

    Some more info about hi-res image printing:
    http://www.alistapart.com/articles/hiresprinting/

    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-‘"
    #27220

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

    Regards

    in reply to: PD4ML Tips & Tricks
    #26206

    Hi,

    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.

    Thanks
    SV

    in reply to: HTML/CSS rendering issues
    #26205

    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 org.zefer.pd4ml.tools.PD4Browser$PD4Converter.o00000(Unknown Source)
    at org.zefer.pd4ml.tools.PD4Browser$PD4Converter.access$800(Unknown Source)
    at org.zefer.pd4ml.tools.PD4Browser.main(Unknown 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
    #27329

    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?

    thanks!
    m

    in reply to: NullPointerException in command line convert
    #27330

    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:

    [language=xml:7ove3m5j]

    [/language:7ove3m5j]

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