Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26356

    I am trying to render an HTML document with Chinese characters into a PDF and it either inserts ??? for the missing characters or it totally ignores them.

    In my logs I see this:

    ENCODING=UTF8
    version: PD4ML 351 Pro
    not yet in cache: file:C:DEVworkspaceECLIPSEportalweb-colotargetworkwebappWEB-INFclassescomxxxxxxxxportalrenderdocument/pd4fonts.properties
    not yet in cache: file:C:DEVworkspaceECLIPSEportalweb-colotargetworkwebappWEB-INFclassescomxxxxxxxportalrenderdocument/xxxx-propu.ttf
    read 'xxxx proportional unicode' from file:C:DEVworkspaceECLIPSEportalweb-colotargetworkwebappWEB-INFclassescomxxxxxxxxportalrenderdocument/xxxx-propu.ttf
    'xxxx proportional unicode bold' is not in pd4fonts.properties file
    reject TTF lookup for: 'xxxx proportional unicode bold'
    'times' is not in pd4fonts.properties file
    reject TTF lookup for: 'times'
    'times new roman' is not in pd4fonts.properties file
    reject TTF lookup for: 'times new roman'
    'akzidenzgroteskbe-bold' is not in pd4fonts.properties file
    reject TTF lookup for: 'akzidenzgroteskbe-bold'
    done in 500ms.

    This is the code that I believe is relevant:

    String pathToPd4fontsProps = "/com/xxxx/xxxx/portal/render/document/pd4fonts.properties";
    URL fontPathURL            = PD4MLDocumentRenderer.class.getResource( pathToPd4fontsProps );
    File fileP                 = new File(fontPathURL.toURI());
    fontPath                   = fileP.getParent();

    Later on in the same method I have this code:

    pd4ml.enableDebugInfo();
    pd4ml.useTTF( fontPath, true );

    I followed the documents on this site to generate my pd4browser.properties, which is located in the same directory as the fonts and contains the following:

    #
    #Wed Mar 24 07:21:32 EDT 2010
    adobe.font.metrics=true
    debug.info.enable=false
    document.author=
    document.title=
    footer.color=#000000
    footer.font.face=Courier New
    footer.font.size=10
    footer.font.style=0
    footer.height=12
    footer.init.page.num=1
    footer.page.num.align=right
    footer.page.num.template=null
    footer.pages.to.skip=0
    footer.title.align=center
    footer.title.template=null
    header.color=#000000
    header.font.face=Courier New
    header.font.size=10
    header.font.style=0
    header.height=12
    header.init.page.num=1
    header.page.num.align=right
    header.page.num.template=null
    header.pages.to.skip=0
    header.title.align=center
    header.title.template=null
    images.interpolate=false
    insets.bottom=10
    insets.left=10
    insets.right=10
    insets.top=10
    insets.units=mm
    page.bookmarks.destinations=false
    page.bookmarks.headings=false
    page.format=A4
    page.hyperlinks=true
    page.orientation=false
    pdf.forms.enable=false
    proxy.host=
    proxy.port=0
    rendering.patch=true
    rendering.split=true
    table.breaks.enable=false
    ttf.fonts.default.monospace=
    ttf.fonts.default.sansserif=
    ttf.fonts.default.serif=
    ttf.fonts.dir=com/xxxx/xxxx/portal/render/document
    userSpace.adjustToContent=false
    userSpace.width=800
    viewer.executeble=acroread.exe
    viewer.params=
    window.height=100
    window.width=100
    window.x=850
    window.y=600

    Finally, my pd4fonts.properties file is located in the same directory as the fonts and pd4browser.properties and it contains the following:

    #this is an autogenerated file. please remove manually any references to copyrighted fonts
    #Wed Mar 24 07:21:32 EDT 2010
    KaiTi_GB2312=SIMKAI.TTF
    xxxx Fixed 2 Unicode=xxxx-fixed2U.ttf
    xxxx Fixed Unicode=xxxx-fixedu.ttf
    xxxx Fixed Unicode B=xxxx-FixedU_B.ttf
    xxxx Fixed Unicode C=xxxx-FixedU_C.ttf
    xxxx Fixed Unicode D=xxxx-FixedU_D.ttf
    xxxx Fixed Unicode F=xxxx-FixedU_F.ttf
    xxxx Prop Unicode B=xxxx-PropU_B.ttf
    xxxx Prop Unicode C=xxxx-PropU_C.ttf
    xxxx Prop Unicode D=xxxx-PropU_D.ttf
    xxxx Prop Unicode F=xxxx-PropU_F.ttf
    xxxx Proportional Unicode=xxxx-propu.ttf

    You see that I have a mention of the Chinese font “KaiTi_GB2312=SIMKAI.TTF” but obviously it never is even mentioned. What am I doing wrong?
    My PDFs do get rendered but either with question marks or with the Chinese characters totally omitted. Please help.

    Thank you,
    Ty

    P.S. If you’re just going to send me to the same link TTF embedding link, it isn’t working. I have pored over that document. (pd4ml-html-css-pdf-tips-tricks-f7/ttf-embedding-t42.html) and it does not work! There must be some missing step. Is it necessary to register the Fonts with the OS? (Tried that, no difference.) I have been trying to get the TTF fonts that you included in the example but I have yet to see them getting picked up.

    #27927

    In order to use a font, registered in the .properties file as
    xxxx Fixed 2 Unicode=xxxx-fixed2U.ttf
    you need to explicitly specify the font face as it appears in pd4fonts.properties file:

    <font face="xxxx Fixed 2 Unicode">Text</font> (or the same via CSS)

    On practice it would be more convenient to rename the bulky font face names in pd4fonts.properties, for example:

    xxxx=xxxx-fixedu.ttf
    xxxx Bold=xxxx-FixedU_B.ttf

    For bold style
    <font face="xxxx"><b>Text</b></font>
    It will look for font face with ” Bold” appended. (” Italic” for italic)

    Important:
    1. TTF embedding is a feature of PD4ML Pro (not Std)
    2. TTF font file should define glyphs, used in the text

    #27928

    Thank you for your reply.

    I did end up getting this to work only by using the ‘setDefaultTTF()’ method.

    (Incidentally, it is really non-intuitive the way the other alternative–embedding them in a JAR–expects that it look for a directory within the jar. I would have expected that notation to be the name of the jar. In any case, I did not use that method because of that ambiguity.)

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.