#1 2025-04-19 07:25:33

sameerpandit
Member
Registered: 2018-06-19
Posts: 7

Need help/direction for WMF file.

Hello,

I have wmf files like the one below :

Sample of WMF file

I am unable to Render/Draw the above wmf accurately in the PdfDocument.

If i tinker with the ScaleX,ScaleY parameters for RenderMetaFile method i am able to get results. However the accuracy isnt 100%.

On the other hand if i try using the VclCanvas.Draw method then images at bottom of page are missing in the Pdf.

Any sort of guidance will be appreciated.

-Sam

PS : I am not using any code worth mentioning. Simply like below :

Sample of code used

PPS : Edited the URLs. Thanks for pointing out RVK.

Last edited by sameerpandit (2025-04-19 08:06:34)

Offline

#2 2025-04-19 07:42:30

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

You might want to fix your links.
They give "Incomplete or wrong Download URL."

Offline

#3 2025-04-19 15:54:54

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

Links are correct now (I guess it was the extra slash at the end).

The GDI+ implementation of SynPDF is far from perfect. It probably lacks some features used which results in a 'corrupt' PDF.

I did notice you used SynPDF. I don't have that installed anymore and the old SynPDF isn't updated anymore. For a more recent version you would need to use mormot.ui.pdf in mORMot2.

With that one I got a 'corrupt' pdf trying to do RenderMetaFile(pdf.Canvas, aMeta, 0.58, 1.30, 0, 0);

When I did pdf.VCLCanvas.Draw(0, 0, aMeta); I did get all the images. But the text wasn't exactly correct.

LmYClIY.png

But I can't speak for the older SynPDF.

Offline

#4 2025-04-22 08:27:15

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

Not sure if more help is needed. It seems that the overlap of letters is due to SynPDF thinking the current font is already set while it is not.
Because I don't know if you have the same issue, I'll let this rest until you indicate this.

Offline

#5 2025-04-22 08:35:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,974
Website

Re: Need help/direction for WMF file.

I guess it depends on the font itself.
Which kind of font is it using there?
Other text seems fine.
Perhaps this kind of font is unsupported.

Offline

#6 2025-04-22 08:44:41

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

No, it's just Arial in the WMF.
When I trace through the code I get in TPdfCanvas.SetPdfFont where is skips the code because of the "// check if this font is already the current font".

But when I look in the actual PDF you get to the point for P.O.No. where there is no "/F1 9.95 Tf" set.
And I can't see that there is any "default" font set for the (or a) PDF.

Q
q
BT
39.67 676.56 Td
(P. O. No:) Tj
ET
Q
q

while above it is this for CUSTOMER

q
/F2 9.95 Tf
BT
39.67 694.54 Td
(CUSTOMER:) Tj
ET
Q
q

All the text which is printed overlapped seem to be missing the font setting. It may be due to some recursive problem where SynPDF thinks there is a current font set while there is not... But since I don't know if the OP has the same issue (in the older SynPDF) I'm not sure if it's worth investigating.

(BTW Rendering this though RenderMetaFile() it actually produces a corrupt PDF. Doing this with Draw(), which used some of the same code, gives above result. So there is also something wrong when doing it through RenderMetaFile)

Last edited by rvk (2025-04-22 08:46:23)

Offline

#7 2025-04-22 10:49:19

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

If I use pdf.Canvas.SetFont before using pdf.VCLCanvas.Draw or RenderMetaFile() it works better. In that case the overlapped letters are gone. Not perfect because it seems SynPDF still doesn't take the correct font but it is doable because now the fallback is to that 'default' font.

I'll wait on OP if help is still needed.

sy8lUqd.png

Last edited by rvk (2025-04-22 10:52:09)

Offline

#8 2025-04-22 12:29:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,974
Website

Re: Need help/direction for WMF file.

You are right, this wmf has sometimes no font in it, for some objects.
AFAICT there is some missing "Arial" or any other font information in the input.
https://gist.github.com/synopse/91c8070 … a2e5cd5e6b

Even emfexplorer is not able to render it properly.
Emf-No-Font.png

This wmf would not render correctly if you just change the Windows version, or the rendering program.
Don't you have any mean of fixing it?

Offline

#9 2025-04-22 12:38:27

rvk
Member
Registered: 2022-04-14
Posts: 131

Re: Need help/direction for WMF file.

That's weird. If I look in the WMF with EMFexplorer I do get some font info, but maybe not for all objects:

Multiple lines with
EMR_EXTCREATEFONTINDIRECTW    (s=368)    {ihFont(2) ELF[name() style() vendor(0x072DDF38)] LOG[face(Arial), style(Bold), charset(0),family(0),precision(0), height(-100), width(0)]}

But it's also weird that some text is correct. For me... every WMF/EMF renderer I used (emfexplorer, gimp, paint and irfanview) do give somewhat correct result (although some give different font results). So they do fall back to a "correct" font as where SynPDF falls back to NO font (giving overlapping characters).

y0mzKIg.png

Last edited by rvk (2025-04-22 12:44:27)

Offline

Board footer

Powered by FluxBB