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
Hi,
Firstly, my apologies for posting a message & disappearing.
Thanks RVK for your enthusiastic replies. I have taken the cue & shifted to mORMot-2. However i am still getting same results as i was getting from SynPdf. (see attached files). My issue is simple : I am using VclCanvas.Draw for past multiple years without any problems. However, the Draw function is skipping the images at the bottom of the page. And yes, i am using D7.
AB, Firstly thanks for SynPdf. We have been using it for multiple years to generate PDFs from the WMFs generated by a report-writer. Trust me i have had NO PROBLEMS with SynPdf till this one. My question is simple : if RenderMetaFile is able to add the images at bottom of page then why is VclCanvas.Draw skipping the images at bottom of page.
Sample Project for Testing (D7/mORMot2)
Offline
I'm not sure why the VCLCanvas.Draw doesn't work for you... but for me it does show the images at the bottom.
I do need to use pdf.Canvas.SetFont otherwise I get an error message in Adobe reader as below. Not sure why you don't get that with your code.
Here is the code I used.
https://gist.github.com/rvk01/9e20e728d … b35107dfbf
Result: https://limewire.com/d/UkxBW#QGNBuFNvep
So make sure you use the pdf.Canvas.SetFont. Do the images at the bottom show up then for you???
Offline
RVK,
Maybe because i am using D7 (for compiling the project) hence we are getting different results on the Draw function.
I shall check out your gist code & report back. However I dont have any issues with fonts if i use SynPdf/D7. So i am sure i can get around that issue (if i shift to mORMot2). My worry is VclCanvas.Draw skipping images below 6 inches (approx).
Regards & thanks
Offline
Also try to ensure you got SynPdf from https://github.com/synopse/mORMot
not from https://github.com/synopse/SynPDF/
Offline
AB,
I shall check the dates & report back. thanks.
Edit : Indeed, the SynPdf i am using has timestamp 11/12/2022. So, you've made some changes which i dont have. I shall download and check tonight. Thanks.
Last edited by sameerpandit (2025-06-24 10:10:34)
Offline
Hi AB,
I downloaded SynPdf from the link provided by you & re-built the project. I still do not get the two images at the bottom of the page.
My current situation :
D7 / SynPdf (latest as per your link) :-> Skipped images at bottom. (Using VclCanvas.Draw)
D7/ mORMot2 : -> Skipped images at bottom. (Using VclCanvas.Draw)
Offline
@sameerpandit did you add the setfont line as I showed?
For me it works here.
(I also linked to my code)
Last edited by rvk (2025-06-24 12:03:01)
Offline
RVK,
Thanks for your inputs. Text issue I shall manage. I need a solution for images at bottom of page being skipped.
Offline
Text issue I shall manage. I need a solution for images at bottom of page being skipped.
You're missing the point. For me, without the setfont, there is a corrupt pdf created. The resulting pdf doesn't show everything. Maybe for you it then doesn't show the images. That's why I asked if you did the setfont.
But I can't help you any further because for me it works (if I do the setfont as in my code).
Offline
@rvk,
I acknowledge & appreciate your help.
However, I am not facing any text issues using SynPdf for past multiple years. In the beginning we had some issues with box-text object in the wmf files which we managed to trace & resolve in the enum function. If I manage to get the images issue resolved then I intend to stay with SynPdf which is working fine for us.
Anyway thanks for your inputs. Much obliged.
Offline
However, I am not facing any text issues using SynPdf for past multiple years.
You are STILL missing the point.
Without the setfont... I get a corrupted pdf.
It doesn't have anything to do with the actual text.
Only with the setfont I get a correct pdf.
If it doesn't work for you (even with adding that one line) then it must be something with D7 (I'm using D20.2).
(Didn't test with Lazarus yet)
Offline
Dear Rvk,
I am NOT facing any text issues without the Setfont. Not in mORMot1. Not in mORMot2. I get correct PDFs using both as far as text objects are concerned.
Thanks for pointing out the Setfont workaround.
Regards.
Offline
I am NOT facing any text issues without the Setfont. Not in mORMot1. Not in mORMot2. I get correct PDFs using both as far as text objects are concerned.
You ARE having issues other than font issues.
You have a problem with images.
I'm just saying setting the font might resolve this (as it did with me). I also didn't have font issues but corruption issues. Nothing to do with font. But setting setfont fixed that for me.
Last edited by rvk (2025-06-24 15:19:02)
Offline
Dear Rvk,
I shall definitely keep in mind your valuable input regarding Setfont.
However, I assure you that before posting here I have done several tests/tracing sessions. All my results suggest that on D7 the problem I described is there.
Offline
Pages: 1