Viewing 15 posts - 1 through 15 (of 27 total)
  • Author
    Posts
  • #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]

    #27298

    Im using the pro version and with domino server 8.5.1
    pd4ml.render(new StringReader(inputHTML), fos, new URL(“file:.”), “iso-8859-1”);

    The notesdocument is grabbed by java agent
    Document usrDoc = db.getDocumentByID(strUNID);

    I can’t get it to display danish characters properly

    i have tried this also
    pd4ml.render(new StringReader(inputHTML), fos, new URL(“file:.”), “utf-8”);

    Eksample:
    Kære = Kære
    pÃ¥ første = på første

    #27299

    I guess inputHTML is a String object.

    What does the following code print to Java console?
    System.out.println(inputHTML);

    Is it “Kære” or “Kære”?

    #27300

    Plz help me, How to set unicode for pdf output.? I set charset utf-8 for my html and display normal, but it create pdf output not read

    #27302

    what are the license terms for the fonts used in http://pd4ml.com/i/easyfonts/fonts.jar? Can we use that in our commercial web application in which we generate and serve pdf to the users?

    #27303

    The fonts are taken from a Win32 distribution and published for educational purposes only. If you own a Windows license, obviously you are allowed to use the fonts in your commercial applications. http://pd4ml.com/examples.zip (chinese_ttf example) provides you with fonts.jar build-script to build the JAR from your very own TTF copies.

    #27304

    Hello,

    I am trying to provide for Asian (CJK) language support in my application. While chinese works out well, the TTF embedding feature doesn’t help in case of Korean or Japanese.
    I followed all the steps mentioned in the online help for generating pd4fonts.properties for these font files.
    In the server logs I can see font files getting resolved. Example, for japanese text, MSminchu.ttf is being loaded (as per the logs), but the generated PDF contains “??????” throughout and the PDF properties – > Font, doesn’t show me msminchu font being loaded.
    When I deliberately try to load chinese font for Japanese text, then I can see some of the content coming fine (that is because Chinese and Japanese languages share some symbols), but ofcourse that would not be a good solution.

    What could be going wrong here? I have been at it for a longtime now. Please help!!

    -Ashish

    #27305

    Please try to substitute your fonts jar with this one:
    http://pd4ml.com/i/allfonts.zip (34 MB!)

    unpack it and place fonts.jar to the classpath of your application (or to lib/ folder if any).
    Refer the fonts this way:
    pd4ml.useTTF(“java:fonts”, true);

    And make sure the HTML has a correct meta charset directive.

    Does it solve the problem?

    #27306

    My spring application has a maven build and I want to set up fonts.jar and pd4ml.properties for this build. Can anyone help me get started?

    #27308

    i have problem with arabic i used

    but the arabic appear with ???? why can any one help me

    #27309

    You defined debug=”true” attribute. That means PD4ML prints to server’s log TTF loading diagnostics.

    Can it lookup requested fonts? Can it load them? The log output should help to determine the problem reason.

    #27310

    13/09/13 04:19:59 version: PD4ML 381fx1 Pro DMS
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/reset.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/reset.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/reset.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/reset.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 6721 bytes: html, body, div, span, applet, object, i
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/template.css?
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/template.css?
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/template.css?
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/template.css?
    13/09/13 04:19:59 RequestDispatcher.include() returned 62208 bytes: body {
    text-align: center;
    mar
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/black.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/black.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/black.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/black.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 3364 bytes: body.black #outer_wrapper {
    backgro
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/calender.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/calender.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/calender.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/calender.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 1908 bytes: .calender {
    width: 220px;
    /*he
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/ui.selectmenu.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/ui.selectmenu.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/ui.selectmenu.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/ui.selectmenu.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 2008 bytes: /* Selectmenu


    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/jquery-ui-1.8.6.custom.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/jquery-ui-1.8.6.custom.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/jquery-ui-1.8.6.custom.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/jquery-ui-1.8.6.custom.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 18640 bytes: .ui-helper-hidden { display: none; }
    .u
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/datePicker.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/datePicker.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/datePicker.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/datePicker.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 2724 bytes:

    table.jCalendar {
    border: 1px soli
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 858 bytes: .ac_results {
    padding: 0px;
    border:
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 858 bytes: .ac_results {
    padding: 0px;
    border:
    13/09/13 04:19:59 looping inclusions found: file:/dp/jsps/css_ar/jquery.autocomplete.css
    13/09/13 04:19:59 loading CSS file file:/dp/jsps/css_ar/keyboard.css
    13/09/13 04:19:59 not yet in cache: file:/dp/jsps/css_ar/keyboard.css
    13/09/13 04:19:59 Loading via HTTP Request dispatcher: /dp/jsps/css_ar/keyboard.css
    13/09/13 04:19:59 Using URL without web application name: /jsps/css_ar/keyboard.css
    13/09/13 04:19:59 RequestDispatcher.include() returned 7223 bytes: #keyboardInputMaster {
    position:absol
    13/09/13 04:20:00 image not yet in cache: file:D:/isoft/projects/DPINT/src/web-online/public_html/
    13/09/13 04:20:00 image size: 7242
    13/09/13 04:20:00 image size: 7242
    13/09/13 04:20:00 image type of file:D:/isoft/projects/DPINT/src/web-online/public_html/ is unknown/unsupported.
    13/09/13 04:20:00 can not load image: ../
    13/09/13 04:20:00 image not yet in cache: file:D:/isoft/projects/DPINT/src/web-online/public_html/Images/Button_default_hover.gif
    13/09/13 04:20:00 image file:D:/isoft/projects/DPINT/src/web-online/public_html/Images/Button_default_hover.gif has zero length.
    13/09/13 04:20:00 can not load image: file:D:/isoft/projects/DPINT/src/web-online/public_html/Images/Button_default_hover.gif
    13/09/13 04:20:00 done in 1072ms.

    #27311

    Note:
    i used this JAR with 3 fonts for serif, sansserif and monospaced types
    http://pd4ml.com/i/easyfonts/fonts.jar (~2MB)

    in webinf/lib

Viewing 15 posts - 1 through 15 (of 27 total)

The forum ‘PD4ML Tips & Tricks’ is closed to new topics and replies.