Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #26574

    Hi,
    if i give the html file to pd4ml which is having utf – 8 char for converting to pdf but in pdf file utf – 8 characters render like ?????
    means, “期購読お申し込” is replaced with “???????”

    I have also declare utf-8 charset in my html file using meta tag

    we have a licence version of pd4ml eventhoug we are not able to convert such html file to pdf with proper data.

    Below is my code :-

    public File runConverter(File inputFileName, File outputFileName) throws IOException
    {
    if (inputFileName != null && outputFileName != null)
    {
    PD4ML pd4ml = new PD4ML();
    pd4ml.enableSmartTableBreaks(true);
    if (inputFileName.length() > 0)
    {
    InputStreamReader isr = new InputStreamReader(new FileInputStream(inputFileName), “UTF-8”);
    java.io.FileOutputStream fos = new java.io.FileOutputStream(outputFileName);

    /* START: CONFIGURATION FOR PAGE ORIENTATION */
    try
    {
    pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    /* END: CONFIGURATION FOR PAGE ORIENTATION */

    /* START: CONFIGURATION FOR PAGE ORIENTATION */
    pd4ml.setPageInsets(new Insets(10, 10, 10, 10));
    /* END: CONFIGURATION FOR PAGE ORIENTATION */

    /* START: CONFIGURATION FOR PAGE HEADER */
    PD4PageMark pageMarkForHeader = new PD4PageMark();
    pageMarkForHeader.setAreaHeight(10);
    pageMarkForHeader.setHtmlTemplate(“Hi, this is for testing only that page is start
    “);
    pd4ml.setPageHeader(pageMarkForHeader);
    /* END: CONFIGURATION FOR PAGE HEADER */

    PD4PageMark pageMarkForFooter = new PD4PageMark();
    pageMarkForFooter.setAreaHeight(10);
    pageMarkForFooter.setInitialPageNumber(10);
    pageMarkForFooter.setHtmlTemplate(“Hi, this is for testing only that page is end
    “); // ${title} for title, ${page} for page number, ${total} for total number of pages
    pd4ml.setPageFooter(pageMarkForFooter);

    pd4ml.setHtmlWidth(780);
    pd4ml.render(isr, fos);
    }
    }
    return outputFileName;
    }

    #28564

    In order to display Asian characters you need to utilize TTF embedding feature of PD4ML Pro:

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

    #28565

    I have tried with the following text :-

    Arabic نيويورك
    Japanese 定期購読お申し込みフォーム
    Russian Эксперт Online
    Other ÆØÅ_æ–øå_ö
    中文名的来源

    and the output is :-
    Arabic نيويورك
    Japanese
    Russian Эксперт Online
    Other ÆØÅ_æ–øå_ö

    means chiness and japanese char display as blank

    i have puted font.jar in web-inf lib folder and i changed my code as you suggested.

    new code is :-

    public File runConverter(File inputFileName, File outputFileName) throws IOException
    {
    if (inputFileName != null && outputFileName != null)
    {
    PD4ML pd4ml = new PD4ML();
    pd4ml.enableSmartTableBreaks(true);
    if (inputFileName.length() > 0)
    {
    InputStreamReader isr = new InputStreamReader(new FileInputStream(inputFileName), “UTF-8”);
    java.io.FileOutputStream fos = new java.io.FileOutputStream(outputFileName);

    /* START: CONFIGURATION FOR PAGE ORIENTATION */
    try
    {
    pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    /* END: CONFIGURATION FOR PAGE ORIENTATION */

    /* START: CONFIGURATION FOR PAGE ORIENTATION */
    pd4ml.setPageInsets(new Insets(10, 10, 10, 10));
    /* END: CONFIGURATION FOR PAGE ORIENTATION */

    /* START: CONFIGURATION FOR PAGE HEADER */
    PD4PageMark pageMarkForHeader = new PD4PageMark();

    pageMarkForHeader.setAreaHeight(10);
    pageMarkForHeader.setHtmlTemplate(“Hi, this is for testing only that page is start
    “);
    pd4ml.setPageHeader(pageMarkForHeader);
    /* END: CONFIGURATION FOR PAGE HEADER */

    PD4PageMark pageMarkForFooter = new PD4PageMark();
    pageMarkForFooter.setAreaHeight(10);
    pageMarkForFooter.setInitialPageNumber(10);
    pageMarkForFooter.setHtmlTemplate(“Hi, this is for testing only that page is end
    “); // ${title} for title, ${page} for page number, ${total} for total number of pages
    pd4ml.setPageFooter(pageMarkForFooter);

    URL base = new URL( “file:C:/tempJava/” );
    pd4ml.setHtmlWidth(780);
    pd4ml.useTTF( “java:fonts”, true );
    pd4ml.setDefaultTTFs(“Times New Roman”, “Arial”, “Courier New”);
    pd4ml.render(isr, fos, base);

    }
    }
    return outputFileName;
    }

    #28566

    As I see you packed TTF fonts into a JAR and correctly refer them:

    pd4ml.useTTF( “java:fonts”, true )

    It looks like your JAR has only popular fonts like Arial, Courier etc. Normally the fonts do not include Asian glyphs. In order to cover the character space please add to the JAR fonts like MS Mincho, MS Gothic, MingLiU and SimSun from any Win32 distribution (you can find them in windowsfonts).

    Here are the entire font name lists, PD4ML tries to use in order to display international texts:
    post1638.html?#p1638

    #28567

    Thanks sir for your reply but please, Can you provided that fonts.jar file which support all the characters..?

    #28568

    Hi,
    is there any update on my above comment because we want the solution urgently?

    #28569

    Please try the following:
    http://pd4ml.com/i/allfonts.zip (34 MB!)
    I assume you own at least one license of MS Win, so there is going to be no font licensing issues.

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

The forum ‘General questions / FAQ’ is closed to new topics and replies.