Jump to content
Sign in to follow this  
Attila Kovacs

PlayEnhMetaFile on non visible area

Recommended Posts

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 by Attila Kovacs

Share this post


Link to post

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.

  • Like 1

Share this post


Link to post

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×