• We are using the WPDFControl control version 2,0 to generate pdf files.
    Our program establishes the following values:

    EnhancedOptions = 0
    SetTextDefaultAttr('Tahoma',10)
    PAGE_PDFHeight = 750
    PAGE_PDFWidth = 650
    PAGE_PDFXRes = size font * 20
    PAGE_PDFYRes = size font * 20

    or

    PAGE_PDFXRes = size font
    PAGE_PDFYRes = size font


    In order to calculate the values x and y for the TextOt function , we used the following one formulates:
    x1 = size field1 * size font
    y1 = y1 + size font

    x2 = x1 + (separator * size font) + (size field2 * size font)

    As we must calculate the values of parameters x, and, w, h for any type of font?

    Thanks

    Note .- we enclosed file with example of generated file

    [/url]

    • Offizieller Beitrag

    Hi,

    the parameter of SetTextDefaultAttr('Tahoma',10) uses the font size in pt. To claculate the height of the font you can use this formula:

    Round(size * yres / 72);

    yres is the screen resolution since the conmtrol uses a screen reference to create the metafile which is used to capture the drawing.

    PAGE_PDFXRes / PAGE_PDFYRes should not be changed.

    You can then use standard windows GDI function for textout

    TextOut( wPDF.DC, x,y, ... )

    Of course you can also create a font there, CreateFont etc.


    Using x1 = size field1 * size font will probably not work alright, the WindowsGDI has the function GetTextExtend for this.

    Julian Ziersch