You are not logged in.
Pages: 1
One of our PDF reports (containing some metafiles drawn by some third-party code outside of our control then copied to PDF) isn't working in the current version of SynPDF.
Most of each page appears blank, and Adobe Reader is complaining that "An error exists on this page."
I have checked against the latest version of SynPDF from GitHub. The report worked in older versions of SynPDF. I did some investigating, and it looks like the "enhanced clipping process" patch's change to TPdfEnum.ExtSelectClipRgn introduced the problem. (In other words, if I edit SynPdf.pas and change back just the TPdfEnum.ExtSelectClipRgn function, my PDFs work.)
I spent some time playing around with ExtSelectClipRgn to see if I could fix the problem, but unfortunately, I'm having trouble figuring out my way around the codebase. I tried the RGN_COPY change described here, and that didn't help.
I can post examples of the functioning and non-functioning PDFs, if that would help. Unfortunately, since the report generator code involves some third party-code, I can't easily share that.
Last edited by jkelley (2016-12-21 23:25:48)
Offline
Hello,
if you can share the not working metafiles i will take a look on these problem
Offline
Thank you.
I've uploaded the metafile to https://dl.dropboxusercontent.com/u/152 … tafile.emf.
Here's a simplified version of the C++ code we're using to create the PDF.
TPdfDocumentGDI *document = new TPdfDocumentGDI(false, CP_UTF8, false, NULL);
document->DefaultPaperSize = psLetter;
document->ScreenLogPixels = 254;
document->DefaultPageLandscape = true;
document->CompressionMethod = TPdfCompressionMethod::cmFlateDecode;
document->AddPage();
TMetafile *mf = new TMetafile;
mf->LoadFromFile("c:\\temp\\metafile.emf");
document->VCLCanvas->StretchDraw(TRect(127, 127, 2667, 2032), mf);
document->SaveToFile("c:\\temp\\file.pdf");
delete document;
delete mf;
Offline
After investigate the clipping in SynPDF i must say there are a lot of problems with it. I will spend some more time to find a proper solution.
But at moment im running out of spare time so it will take some weeks.
Offline
Thank you very much for looking into this.
In case anyone else runs into this problem, I was able to get my code working again simply by reverting the enhanced clipping process patch in my local copy of SynPDF (so I don't have any immediate needs for a fix).
Offline
I reverted this patch.
Offline
Hello,
Just wanted to point out that after installing yesterday's version (fe6aa68421) the clipping issue is still not solved. I'm hoping for someone to take care of this, I'll try myself, but I'm no expert.
We're using Unicode, Builder XE5.
Oh and also, there's an error, multiple declaration of ESynException in SynCommons when compiling.
Offline
Hello,
I have the exactly same issue using the latest nightly build. If I just revert the following function:
procedure TPdfEnum.ExtSelectClipRgn(data: PRgnDataHeader; iMode: DWord);
var ExtClip: TRect;
begin
try
ExtClip := data^.rcBound;
with DC[nDC] do
case iMode of
RGN_COPY: begin
ClipRgn := MetaRgn;
ClipRgnNull := False;
end;
end;
except
on E: Exception do ; // ignore any error (continue EMF enumeration)
end;
end;
To his previous version:
procedure TPdfEnum.ExtSelectClipRgn(data: PEMRExtSelectClipRgn);
var RGNs: PRgnData;
i: Integer;
RCT: TRect;
ClipRect: TPdfBox;
begin // see http://www.codeproject.com/Articles/1944/Guide-to-WIN-Regions
if not DC[nDC].ClipRgnNull then begin
Canvas.GRestore;
Canvas.NewPath;
Canvas.fNewPath := False;
DC[nDC].ClipRgnNull := True;
fFillColor := -1;
end;
if Data^.cbRgnData>0 then begin
Canvas.GSave;
Canvas.NewPath;
DC[nDC].ClipRgnNull := False;
RGNs := @Data^.RgnData;
for i := 0 to RGNs^.rdh.nCount-1 do begin
Move(Rgns^.Buffer[i*SizeOf(TRect)], RCT, SizeOf(RCT));
Inc(RCT.Bottom);
ClipRect := Canvas.BoxI(RCT, False);
Canvas.Rectangle(ClipRect.Left,ClipRect.Top,ClipRect.Width,ClipRect.Height);
end;
Canvas.Closepath;
Canvas.Clip;
Canvas.NewPath;
Canvas.FNewPath := False;
end;
end;
All become fine again and I can use the latest nightly build without problems.
Regards
Offline
After many research, I found a solution to my issue.
The clipping is fixed if I use : RenderMetaFile(pMetaFile, 1, 0, 0, 0, tpSetTextJustification, 99, 101, tcNeverClip);
Instead of : RenderMetaFile(pMetaFile, 1, 0, 0, 0, tpSetTextJustification, 99, 101, tcAlwaysClip);
For a long time, I was using this method like this : RenderMetaFile(pMetaFile, 1, 0, 0, 0) and only discovered recently the TPdfCanvasRenderMetaFileTextClipping parameter!
I hope this will help other people with the same issue! :-)
Offline
Pages: 1