#1 2015-02-20 15:23:49

topet
Member
Registered: 2015-02-20
Posts: 2

Parts of EMF are strange printed to PDF

I'm using the SynPdf in Version 1.18 and have the problem that parts of the EMF are not printed as aspected.
   
What I do:
- Using TChart to create a Chart and use the TChart-Function TeeCreateMetafile() to get a TMetafile.
- this Metafile is drawn to the TPrintPreview Canvas using StretchDrawGraphic()
- finally I use SynPDF to create the PDF-Document

The EMF is a chart that contains one Dataseries. The Dataseries is horizontal longer than the chart itself.
The chart is printed correctly on the preview and on a printer directly but when I'm using synPDF the dataseries is drawn beyond the chart-borders.

I created a correct PDF (EMF-OK) and one that shows the error (EMF-Strange) as well as the EMF-File (chart.emf) all zipped and available here
https://drive.google.com/file/d/0BwnbjR … sp=sharing

If anyone as an idea or hint, please let me know.
Regards, topet

Offline

#2 2015-02-21 12:10:48

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

Re: Parts of EMF are strange printed to PDF

Try with the latest patch about clipping region.
See http://synopse.info/fossil/info/716bbd23f6

Offline

#3 2015-02-25 10:50:29

topet
Member
Registered: 2015-02-20
Posts: 2

Re: Parts of EMF are strange printed to PDF

Thank you ab for the fast response.

I updated the files to 1.18.973 but the PDF still looks strange.
When I place a breakpoint on the changed code section (SynPdf.pas, function EnumEMFFunc() in case EMR_INTERSECTCLIPRECT) the Debugger didn't stop there.

Does it may have something to do with GDI content, since a comment on the functions says that it doesn't render GDI completely yet?

Regards, topet

Offline

#4 2015-03-16 11:14:01

cosina
Member
Registered: 2015-03-16
Posts: 1

Re: Parts of EMF are strange printed to PDF

I'm using this workaround (which is still far from being perfect) but at least works for me:

  EMR_EXTSELECTCLIPRGN: begin
    E.fStrokeColor := -1;
    E.fFillColor := -1;
    E.fPenStyle := -1;
    E.fPenWidth := -1;
    E.fStrokeColor := -1;
    E.Canvas.Page.Font := nil ;
    E.Canvas.GRestore ;
    E.Canvas.GSave ;
    E.ExtSelectClipRgn(@PEMRExtSelectClipRgn(R)^.RgnData[0],PEMRExtSelectClipRgn(R)^.iMode);
  end ;
  EMR_INTERSECTCLIPRECT: begin
    E.fStrokeColor := -1;
    E.fFillColor := -1;
    E.fPenStyle := -1;
    E.fPenWidth := -1;
    E.fStrokeColor := -1;
    E.Canvas.Page.Font := nil ;

    E.Canvas.GRestore ;
    E.Canvas.GSave ;
    ClipRgn := e.IntersectClipRect(e.Canvas.BoxI(PEMRIntersectClipRect(r)^.rclClip,true),ClipRgn);
    with e.Canvas.BoxI(PEMRIntersectClipRect(r)^.rclClip,true) do
      e.Canvas.Rectangle(Left,Top,Width,Height);
    e.Canvas.Clip;
    e.Canvas.NewPath;
  end;


I also implemented:

procedure TPdfCanvas.Comment( text : String );
begin
  if FContents<>nil then
    FContents.Writer.Add('%' + text + #10);
end;

It is a pretty good help for debugging PDF output. I inject EMF sentences so I'm able to manually alter PDF file without guessing what was responsible for particular pdf sequence.

Offline

Board footer

Powered by FluxBB