#1 2016-01-26 14:24:06

chachora
Member
Registered: 2016-01-26
Posts: 5

Wrong rendering of TeeChart Metafile

Metafile generated by TeeChart is not rendered correctly.
When I render it with bitmap, I get the following image:
bmp.png
But in pdf it is completely wrong:
pdf.png

This is my code:

var
  PdfDoc: TPdfDocumentGDI;
  PdfPage: TPdfPage;
  ChartMetafile: TMetafile;
  bmp: TBitmap;
begin
  ChartMetafile := nil;
  bmp := nil;
  PdfDoc := TPdfDocumentGDI.Create(False, 0, true, nil);
  try
    PdfPage := PdfDoc.AddPage;
    PdfPage.PageLandscape := true;

    ChartMetafile := Chart.TeeCreateMetafile(False, Rect(0,0, PdfPage.PageWidth, PdfPage.PageHeight));

    bmp := TBitmap.Create;
    bmp.Width := ChartMetafile.Width;
    bmp.Height := ChartMetafile.Height;
    bmp.Canvas.Draw(0, 0, ChartMetafile);
    bmp.SaveToFile('c:\temp\test.bmp');

    PdfDoc.VCLCanvas.Draw(0, 0, ChartMetafile);
    PdfDoc.SaveToFile('c:\temp\test.pdf');

  finally
    PdfDoc.Free;
    ChartMetafile.Free;
  end;

I tried it with RenderMetafile also, it gave the same result. What can be the problem?

Last edited by chachora (2016-01-26 14:28:05)

Offline

#2 2016-01-26 14:28:04

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

Re: Wrong rendering of TeeChart Metafile

Are you using the latest revision of the library?
Current is 1.18.2306.

We use this in production, with no problem - but not from TeeChart as source.
There is even a dedicated test very close to this in our regression tests - see TestSQL3.pdf as generated by TestSQL3.exe.

Offline

#3 2016-01-26 14:31:33

chachora
Member
Registered: 2016-01-26
Posts: 5

Re: Wrong rendering of TeeChart Metafile

I've downloaded it from GitHub, version is 1.18, but there is not build number mentioined.

Offline

#4 2016-01-26 14:53:20

chachora
Member
Registered: 2016-01-26
Posts: 5

Re: Wrong rendering of TeeChart Metafile

I downloaded the latest mORMot, but still the issue remains.

Offline

#5 2016-01-26 15:37:21

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

Re: Wrong rendering of TeeChart Metafile

Could you put a link to the .emf file?

Offline

#6 2016-01-27 06:20:06

chachora
Member
Registered: 2016-01-26
Posts: 5

Re: Wrong rendering of TeeChart Metafile

I have tried to export with different settings and it worked!
Finally, I found the settings of TeeChart when the problem starts:
1. GDI+ shall be selected as a Render
2. 3D mode shall be enabled
3. Any series have to be on the chart.

When I changed the render to GDI or disable 3D mode, library works just fine.
Emf files are below:
1. GDI and 3D
3d_gdi.emf
2. GDI+ and 3D
3d_gdi+.emf

Offline

#7 2016-01-27 12:44:59

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

Re: Wrong rendering of TeeChart Metafile

In fact, there is no EMF+ file standard.
The GdiPlus library does not support such kind of serialization.

The SynPDF library expect indeed valid EMF content as input.
Here is the rendered content:
Test_SQLite3_Pages_Copie_2_Page_1.jpg

Offline

#8 2016-01-31 06:33:44

chachora
Member
Registered: 2016-01-26
Posts: 5

Re: Wrong rendering of TeeChart Metafile

So, it means that TeeChart exports to EMF file with wrong format when GDI+ and 3D enabled in the settings?

Offline

#9 2016-01-31 12:55:04

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

Re: Wrong rendering of TeeChart Metafile

Yes, it seems that TeeChart creates not a true EMF file, but some EMF-like format.
So you should create a true EMF format, using plain GDI, without 3D.

Offline

#10 2017-12-13 13:03:39

MtwStark
Member
From: Italy
Registered: 2016-01-05
Posts: 27

Re: Wrong rendering of TeeChart Metafile

I use TeeChart and print them on PDF with SynPDF

MyChart.SaveToMetafileEnh(Filename);

saves a valid EMF file.

Offline

Board footer

Powered by FluxBB