Attila Kovacs 629 Posted May 30, 2019 (edited) I'm trying to draw metafiles with "PlayEnhMetaFile" on SynPDF's VCLCanvas (which is a TMetafileCanvas) and somehow the images in my metafile are not drawn if they are vertically below the displays Y resolution. For example, the A4 page has at 96 DPI a height of 1124, the display has a height of 768 or 800 pixels, the metafile should be played at 770 in a height of 120, the images are missing from the result. Textst are drawn but "EMR_STRETCHDIBITS" wont be called in the GDI Enum. Any help/hint would be greatly appreciated. This drives me crazy. Ps: On Printer Canvas no problems, on bigger display with bigger resolution the same code is working. Edited May 30, 2019 by Attila Kovacs Share this post Link to post
PeterBelow 238 Posted May 30, 2019 A metafile canvas can be created with a reference device context handle. If you do not specify one it uses the screen dc as reference. Specify a printer canvas handle as reference, that should work better. 1 Share this post Link to post
Attila Kovacs 629 Posted May 30, 2019 Indeed, but I can't just pass any random printer DC as reference, what if there is no printer installed at all. (Not to mention the DPI difference between printer dc and 72 DPI PDF) I was passing SynPDF's VCLCanvas as reference, but it's the same as I would pass 0, as in SynPDF.pas: // retrieve the current reference GDI parameters FDC := CreateCompatibleDC(0); If I replace this with CreateDC(one of my printer) I can indeed print to the bottom of the page, but as I mention, this results in a 600DPI PDF and I can't just pick a random printer. Share this post Link to post
PeterBelow 238 Posted May 30, 2019 I'm just guessing here, since I don't know this component. You may have to use GDI functions like SetViewportExtEx to modify the device context "size" before drawing on it. Share this post Link to post
Attila Kovacs 629 Posted June 2, 2019 It has nothing to do with the "component", nor with SetViewportExtEx. It's the same problem as described here: https://stackoverflow.com/questions/30386615/copying-a-graphic-to-a-tmetafilecanvas-outside-the-screen-dimensions For me it looks like a windows bug. Share this post Link to post