Scaling problem in wPDFControl using .NET

  • I am evaluating the wPDFControl for our application. I currently have a test app that draws a WMF file (sourced at 300 dpi) onto a screen PictureBox then overlays text onto it for display using a function that accepts a GDI+ Graphics object pointing to the underlying PictureBox.

    A Print option in the app uses DrawImage(picturebox.Image, ...) then the same text overlay function, but passing the Graphics object of the printer page instead of the screen PictureBox (i.e. the text overlay is "device independent").

    The text overlay function works correctly for both screen and printer, despite the differences in DPI resolution (96 vs 300) and the underlying device drivers, by looking at the resolution and then scaling x,y coordinates appropriately.

    I expected to be able to use the Canvas property to do the same for PDF output as I do for printing, i.e. use DrawImage(picturebox.Image ...) then call the text overlay function passing in the Canvas since it is already a device independent function. When I do this, I get somewhat different results than I expected: although everything draws, the entire output (image plus overlayed text) is scaled slightly large, so that everything is cropped on the right side. The code works for both the Printer Graphics and screen Graphics objects, but not the PDF Canvas!

    I tried drawing the WMF directly using the wPDFControl DrawMetafile (telling it the source resolution was 300 DPI), and it DID render the WMF correctly... but had a strange effect on the overlayed text, shrinking it in x,y location and size by a large factor (6 or so), i.e. drawing the metafile had the effect of changing the DPI in behavior, even though the DPI property continues to return 96.

    Two questions:
    1. Is there some setting I can turn on, or some magic parameters to Canvas.DrawImage I can use, so that the solution used for the Printer (using DrawImage of the picturebox .Image) is correctly scaled as it is on the Printer, instead of 15% or so too big?

    and...

    2. What is happening to the scaling when wpdfControl.DrawMetafile is used? Is there some setting I can change afterwards to fix this? Setting PageScale isn't good enough, because the font size itself was affected too when the WMF was drawn, not just the x,y locations (i.e. it really does appear that the DPI is changed to some much bigger number, despite the fact that the DPIx and DPIy properties continue to return 96).

    Thanks!

    • Offizieller Beitrag

    Hello,

    >>Two questions:
    1. Is there some setting I can turn on, or some magic parameters to Canvas.DrawImage I can use, so that the solution used for the Printer (using DrawImage of the picturebox .Image) is correctly scaled as it is on the Printer, instead of 15% or so too big? <<

    No, there is no additional parameter. The DarwMetafile resolution parameter are used to replace the intern detection of the metafile resolution. It does not help much if the resolution is then changed through SetWorldTransform or SetViewPort API calls.

    >> 2. What is happening to the scaling when wpdfControl.DrawMetafile is used? Is there some setting I can change afterwards to fix this? Setting PageScale isn't good enough, because the font size itself was affected too when the WMF was drawn, not just the x,y locations (i.e. it really does appear that the DPI is changed to some much bigger number, despite the fact that the DPIx and DPIy properties continue to return 96). <<

    Can you mail the EMF file to support(at)wptools.de ?

    I would like to check out if somethiung can be improved here.

    Julian Ziersch