#1 Re: PDF Engine » Clipping of a large metafile when outputing to a PDF » 2025-12-18 06:05:17

rvk wrote:

If I use EMFexplorer I also see the run-off (so no clipping).
If I disable "Use GDI+" there (via Document, uncheck "Use GDI+"), the clipping does occur correctly.

In mormot.ui.pdf there is a RenderMetaFile() function (with EnumEnhMetaFile and a clipping parameter).
Did you try that?

What is the code to print after aMeta.LoadFromFile because I couldn't get the dimensions correct?
With factor scaling 0.1 the result I got here is this: https://i.imgur.com/afa83Iy.png
Which seems to be correct regarding the clipping.

Did you use the latest mormot2 (and not the old SynPdf source) ?

Hi,

I'm using the latest SynPDF (downloaded from here https://github.com/synopse/SynPDF), source code bellow.
I'm going to try the mormot.ui.pdf and get back to you.

Thanks!


Metafile := TMetafile.Create;
Metafile.LoadFromFile('D:\Temp\EMF\SynPDF.RenderMetaFile\13.emf');
Metafile.Enhanced := false;

lPdf := TPdfDocumentGDI.Create;
lPdf.ScreenLogPixels:=600;
lPage := lPDF.AddPage;
lpdf.VCLCanvas.Draw(0,0, metafile);
lPdf.SaveToFile('D:\Temp\EMF\SynPDF.RenderMetaFile.13.NoText.pdf');

#2 PDF Engine » Clipping of a large metafile when outputing to a PDF » 2025-12-17 13:16:33

Georgi
Replies: 4

Hi,

I'm trying to save a large tree into a PDF file. The way it has worked so far is to have the tree moved around with only a portion overlapping the page and clipping rectangle making sure the page has margins and headers and stuff. This whole thing is then printed to a PDF printer and has worked well.

I'm now trying to reuse this code and print to a TPdfDocumentGDI using VCLCanvas.Draw(x,y, metafile). The issue I'm writing here about is that the tree is not getting clipped as I'm expecting (or hoping) to. It is getting outside.

I tried checking the EnumEMFFunc to see if some of the records in my metafile are not getting handled and got this list:
Unknown EMR: R^.iType=20 (EmfSetROP2)
Unknown EMR: R^.iType=115 (EmfSetLayout)
Unknown EMR: R^.iType=13 (EmfSetBrushOrgEx)

With the iType=20 (EmfSetROP2) showing up a bunch of times.

I really have no reason to single out the enumeration of the metafile record, no to focus on EmfSetROP2, it is just where I'm starting diagnosing this.

Can you suggest where I should look or what should I look for? Or any suggestion where to start picking at the issue?

I'm attaching, via OneDrive, the metafile, how it looks when saved to PDF via source code, and how it looks when printed via PDF printer(i.e. how I want it to look).

Metafile: 13.emf
via SynPDF code:SynPDF.RenderMetaFile.13.pdf
via PDF Printer: 13.PrintToPDF.pdf

Thanks!

Board footer

Powered by FluxBB