WPDF and font issues with HTML

  • We are using v4 of WPDF along with THtmlViewer for rendering PDF's that contain HTML. The method of rendering the HTML to the PDF is basically this:

    MetaFile := html.MakeMetaFile(0, html.Width, html.Width, html.Height);

    try

    Canvas.StretchDraw(Html.BoundsRect, MetaFile);

    finally

    MetaFile.Free;

    end;

    The problem we are seeing is that the rendering of the font is incorrect in two ways:

    1. The hyperlinks "appear" as hyperlinks (blue with underlines) but don't seem to be treated by the PDF reader as hyperlinks. If the displayed text of the <a> tag is also the link (e.g. href attribute value is the same as the content of the anchor element), then Adobe seems to be treated that text as a hyperlink on its own

    2. If the text contains a "w" then a space is appearing after the "w". This is causing an issue with #1 above if the URL contains a "w" - the link gets broken at the "w" and doesn't work properly.

    This is using Arial, 8pt. If I change to a different font such as Times New Roman, the problem goes away.

    Any suggestions?

    Thanks

    • Offizieller Beitrag

    Hyperlinks require special code to be created in PDF. Our productr WPTools will create the required annotations.

    The rendedering of text is change by the fontmode. The CIDFont mode will place each character individually. If the rendering resolution is small rounding errors can occure. The solution is to use printer resolution to render by selecting "Printer" in property CanvasReference. If you create metafiles youself, you can also specify the Handle of the printer as reference DC for the metafile.

  • I'm investigating the same issue. I viewed the EMF file after setting wPDF.CanvasReference := wprefPrinter and wPDF.DebugMode := true. It appears that changing the CanvasReference corrected the issue for the Label elements but HTML elements still contain the extra space after "w" which breaks the hyperlink. Do you have any more recommendations?