You are not logged in.
Pages: 1
Hello
I started using this great library and it works really good.
But when converting a small EMF file to PDF I encountered a clipping problem, and I don't know how to solve it.
http://sharesend.com/thr2lv3k - EMF-File
http://sharesend.com/w79yhbu8 - converted PDF with synopse
http://sharesend.com/69xdiuvm - converted PDF with Adobe
Are there any settings I can use to adjust the clipping behavior in the PDF Engine?
Best regards
Tom
Offline
After digging into the EnumEMFFunc I see at least two problem areas concerning the emf conversion:
1. Clipping of geometric objects is not implemented (only rectangular clipping of a text is supported).
2. Rendering of chord/arc is not implemented.
http://sharesend.com/qummwept - EMF-File
http://sharesend.com/npm7mf9k - converted PDF with synopse
I used the following code to generate the PDF:
procedure TForm1.Button1Click(Sender: TObject);
var
oPDF: TPdfDocumentGDI;
oMeta: TMetaFile;
begin
oPDF:= TPdfDocumentGDI.Create;
oMeta:= TMetaFile.Create;
try
oMeta.LoadFromFile('c:\temp\test.emf');
oPDF.AddPage;
oPDF.Canvas.RenderMetaFile(oMeta, 1, 0, 0, tpExactTextCharacterPositining);
oPDF.SaveToFile('c:\temp\test.pdf');
finally
oPDF.Free;
oMeta.Free;
end;
end;
Is this correct and are there plans to enhance these areas?
Best regards
Tom
Offline
Hi,
I'm getting great results with this library, it made generating a Pdf really easy. But I also noticed that clipping for EMF is not supported. So far I managed to get around with a hack, but now I'm looking for a proper solution.
Would be great to see an update on that soon.
Cheers
Offline
Well right after I posted the above message, I guess I found part of the bug. I made a quick fix that works, at least for a single clipping rectangle.
In SynPdf.pas in the function EnumEMFFunc, change the EMR_INTERSECTCLIPRECT statement:
EMR_INTERSECTCLIPRECT:
begin
ClipRgn := e.IntersectClipRect
(e.Canvas.BoxI(PEMRIntersectClipRect(r)^.rclClip,
true), ClipRgn);
e.Canvas.Clip;
with e.Canvas.BoxI(PEMRIntersectClipRect(r)^.rclClip, true) do
e.Canvas.Rectangle(Left, Top, Width, Height);
e.Canvas.EoClip;
end;
Furthermore, I noticed a bug in TPdfCanvas.EoClip, instead of upper case W, lower case w should be added to the stream, so:
procedure TPdfCanvas.EoClip;
begin
if FContents <> nil then
// FContents.Writer.Add('W*'#10);
FContents.Writer.Add('w*'#10);
end;
Offline
I've included the fixes.
See http://synopse.info/fossil/info/716bbd23f6
Hope it helps.
Thanks for the patch!
Offline
Hello Marsh
Thanks for your patch.
I tried it but unfortunately the changes in EnumEMFFunc leads to a corrupt PDF.
Please see the EMF and the resulting PDF:
http://sharesend.com/3yijqymn - EMF-File
http://sharesend.com/y1b91w22 - corrupt PDFFile
Best regards
Tom
Offline
Hi Tom,
sorry for my delayed answer.
Yeah I noticed that problem, that's why i mentioned it works for a single clipping rectangle only. I couldn't figure out yet how to resolve that issue unfortunately.
Offline
Furthermore, I noticed a bug in TPdfCanvas.EoClip, instead of upper case W, lower case w should be added to the stream, so:
procedure TPdfCanvas.EoClip; begin if FContents <> nil then // FContents.Writer.Add('W*'#10); FContents.Writer.Add('w*'#10); end;
Hello Marsh
Thanks for your patch.
I tried it but unfortunately the changes in EnumEMFFunc leads to a corrupt PDF.
Sorry Marsh but in current PDF Reference 1.7 EoClip MUST be 'W*' (uppercase)
maybe this could be the cause of your EMR_INTERSECTCLIPRECT bringing to corrupted pdf?
Tom, could you test it with 'W*' instead of 'w*' in EoClip?
kind regards
Offline
** UP **
Can anyone correct the EoClip function?
'w*' means nothing in PDF reference, it should be 'W*'
thanks
Offline
Please check http://synopse.info/fossil/info/6a1377a734
Offline
Hello all
MtwStark solved all the above clipping problems with his SynPDF.pas unit enhancements.
He posted the unit in the topic: PDFEngine Clipping Implementation + Output stream optimizations
Thanks for the great work MtwStark.
Best regards
Tom
Offline
Pages: 1