You are not logged in.
Pages: 1
Hello,
I have wmf files like the one below :
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 :
PPS : Edited the URLs. Thanks for pointing out RVK.
Last edited by sameerpandit (2025-04-19 08:06:34)
Offline
You might want to fix your links.
They give "Incomplete or wrong Download URL."
Offline
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.
But I can't speak for the older SynPDF.
Offline
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
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
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.
Last edited by rvk (2025-04-22 10:52:09)
Offline
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.
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
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).
Last edited by rvk (2025-04-22 12:44:27)
Offline
Pages: 1