rich text to pdf (using metafile and keeping font look)

  • Hi all
    Maintaining an application and unfortunately changing the pdf version is switching the PDF created from using an ANSI encoding (2.1.3) to using a Custom encoding (2.6.5 and above) for fonts (visible in file properties)

    The application is in Delphi 6 and the WPDF components are being used (TWPDFPrinter), text being transferred I believe via such code as
    LineTo(Canvas.Handle,LeftDots+WidthDots,TopDots + H);
    (Not my code, just catching up in the area)

    I've looked at FontMode, which seemed to give no change on settings

    Found out the general terms of the two
    *"Custom" means that an encoding table is *explicitly* defined within
    the PDF file.
    It does not matter what the mapping is used, the document will always
    be displayed and printed equally on any platform/printer (because of
    explicitly mapping).

    *'Ansi' (or 'Roman', or 'Expert') implies an implicit (but the
    predefined) mapping. It means that the PDF file does not contain an
    encoding table, but a viewer/printing application internally uses one
    of predefined encoding tables

    The issue basically is letters cut off, So R would be missing part of the upper curve, or 'w', where the last part of the w is cut off.

    Anyone with experience with this and know the right property to set?
    Or is it a case of resetting a lot of various fonts :(

    Thanks

    Einmal editiert, zuletzt von Redman (24. Januar 2008 um 00:12)

    • Offizieller Beitrag

    Hi,

    wPDF will always use WinANSI Encoding with a few modification to map the characters of the current character set.

    The exception is only the CidMode - here the encoding is not used. Instead character ids are stored which are mapped to glyph positions in the embedded font file. In the case of wPDF the character IDs are the same as the unicode values of the characters. Other PDF creators simply use 1,2,3 ..

    Julian

  • Cheers Julian

    When did it start using the 'few modifications'? After Version 2.1?
    I've attached an image to explain more clearly the difference, the first line is 2.6, and has occured also with 2.8.

    The 2nd line is version 2.1 (just screen shotted each and put them in the one picture)

    Both use exactly the same code (executable is not recompiled)

    [Blockierte Grafik: http://www.microgenx.com/fontdifference.JPG]

  • Thanks again
    It appears though that I'm in for a world of pain.

    The original developer looks to have used the screen resolution as a starting point for making the fonts as identical as they could be between PC's (instead of using the printer driver).

    A draw command print_xywh was being used and I switched this to Draw, and used ScreenResMode rm1440.
    This altered the font dramatically, but fixed the font clipping occuring.

    Its had a side effect of only printing the last line of multiline text, but this could be related to how the code works.

    A couple of questions
    The intention originally I believe was to take what was created, and mirror that exactly across all PC's in a PDFdocument (hence why the printer driver was not used), is using this screenresmode the right way to go about it?

    I got the impression (from a thread) that using rm1440 meant you sacrificed font quality?

  • Progressing
    Only printing the last line was a mix up in parameters of the Draw command.

    Found this thread
    http://www.wpcubed.com/forum/viewtopi…ghlight=wysiwyg
    Which makes me feel I'm doomed if I want consistent output.

    Anyway, font issue cutting off is fixed, the appearance of the font is slightly shorter in height, but consistent.
    Thanks for the help Julian. Question is still out there about it changing between differenct PC's, and what level of change would be expected.

  • My problem now is just tied to Screen resolution.

    The Rich text fields are copied into the PDF using a Metafile canvas.
    The threads
    http://wpcubed.com/forum/viewtopi…setviewport+api


    seemed to indicate I can set a resolution of a metafile.
    Can you explain this in better detail?
    SetMapMode(DC, MM_ANISOTROPIC);
    SetWindowExtEx(DC, WantedResX, WantedResY, nil);
    SetViewPortExtEx(DC, IsResX, IsResY, nil);
    SetViewPortOrgEx(DC, 0, 0, nil);

    • Offizieller Beitrag

    Hi,

    Wehn you use a printer DC as reference for your metafile it usually works a lot better.

    wPDF simply converts the GDI coordinates 1:1 into PDF coordinates. So if you use a changed resolution you can have a higher precision. Unfortunately PDF is limited to 32K coordinates, though.

    But wptools will use its own virtual coordinates. If you use ScreenRes
    ode=rmNormal and the printer as reference you should get a high resolution metafile.

    Julian