Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27001

    For test purposes, I have created a simple html file which has a simple table with the width of 600 pixel and a single row and column containing a little text snippet with font size 20pt and font family Verdana.
    If I generate a pdf file from the html file mentioned above using pd4ml pro, the created pdf file contains a table with exactly 600 pixel as well but the width of the text snippet (I measured the width of the whole text with a pixel ruler tool) is about 70 pixel less than the width of the same text displayed in the browser(displaying the original html file).

    That’s the important part of the pd4ml generation code:

    PD4ML pd4ml = new PD4ML();
    pd4ml.setPageSize(PD4Constants.A4);
    pd4ml.setHtmlWidth(793);
    pd4ml.setPageInsets(new Insets(0, 0, 0, 0));
    ……
    As you can see I set the html width to 793 pixel, which corresponds to the width of A4 with 595 points (I did the test on a windows machine which uses 96 dpi, what means that 595 points corresponds to 595 point * 1,3333 = 793 pixel, I think).
    Furthermore I did not set any insets.

    So I think I can calculate the scale factor the following way:

    (pageFormat.width – pageInsets.left – pageInsets.right) / htmlWidth = scale

    (595 pt – 0 – 0) /(595 pt ≙ 793 px) = 1

    Although the scale factor is 1, the width of the text within the generated pdf file has not the same size as the same text displayed by the browser.

    What did I wrong?

    #29696

    A text width also depends on a particular font used.

    By default (when no TTF embedding configured), PD4ML outputs PDFs refer to Acroread’s built-in Type1 fonts; a Web browser most probably uses standard TTF from OS.

    Helvetica of Acroread looks very similar to Arial, but in fact they are not exactly the same (especially in glyph widths). Probably that is the reason.

    Try to configure TTF embedding and compare PDF and rendered HTML again.

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

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