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

    Hi all,

    I am trying to generate RTF files from templates, and most of the html elements are successfully translated.
    However, I have a problem with fonts.
    In particular, I was not able to convert Arial fonts in HTML to Arial fonts in RTF.
    I have a production server on Unix, and I have a testing server on Mac and I was not successful on any.

    My local testing code that also fails is as follows:
    <br /> public static void test()<br /> {<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.outputFormat(PD4ML.RTF);<br /> String preparsedTemplate = "<html> <head> <title>HTML Online Editor Sample</title> </head> <body> <h1> <span style="color:#00ff00;font-family:'Arial'"><span style="background-color: rgb(255, 0, 0);">Hello world !</span></span></h1><br /> <font face="Arial" color="green">This is some text!</font><br /> </body></html>";<br /> <br /> try {<br /> pd4ml.useTTF( "java:fonts", true );<br /> } catch (FileNotFoundException e2) {<br /> e2.printStackTrace();<br /> }<br /> pd4ml.setDefaultTTFs("Times New Roman", "Arial", "Courier New");<br /> pd4ml.enableDebugInfo();<br /> <br /> FileOutputStream f;<br /> try {<br /> f = new FileOutputStream("/Users/zprotic/Desktop/Documents/test.rtf");<br /> pd4ml.render(new StringReader(preparsedTemplate), f);<br /> } catch (Exception e) {<br /> e.printStackTrace();<br /> }<br /> }<br />
    I have a fonts.jar file in my classpath, with the mentioned fonts.
    The debug info is as follows:
    <br /> not yet in cache: java:fonts/pd4fonts.properties<br /> not yet in cache: java:fonts/arialbd.ttf<br /> read 'arial bold' from java:fonts/arialbd.ttf<br /> not yet in cache: java:fonts/arial.ttf<br /> read 'arial' from java:fonts/arial.ttf<br />

    The generated header font (on Mac) is Geneva, and the generated body font is unknown (empty on Word 2011 for Mac).
    Attached is the generated RTF file.

    Can anyone help with this issue ?

    EDIT: After pointed out by colleagues, I have found out that in OpenOffice, the resulting font is ArialMT or Arial-BoldMT for the header.

    #29370

    By RTF generation, in fact, PD4ML does not embed TTF fonts to the resulting document (I am even not sure if RTF file format supports that), but writes a font family reference to let RTF viewer resolve it.

    As I see in the RTF src, it refers to Win32-specific fonts, which is obviously not correct:
    [language=java:288zz1ss]{f1 Arial-BoldMT;}{f2 ArialMT;}[/language:288zz1ss]

    Try to disable TTF Embedding by RTF generation (exclude pd4ml.useTTF() call). Does it change anything?

    #29371

    I commented out the useTTF call, and I switched to my purchased version of pd4ml ( I tried the example with latest demo version since I had older pro version, and wanted to check if the latest demo version has fixed the problem).
    The solution does not work in Word on MAC- instead of Arial now there is Geneva font everywhere (but in OpenOffice I can see the Arial instead of the ArialMT fonts).

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

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