#1 2024-07-04 08:57:38

RedVit
Member
Registered: 2024-07-04
Posts: 5

Issue when frawwing metafile on canvas

Hi, I'm currently working on an internal project where I have to generate some PDF files. Currently I'm trying to draw some TMetafile objects on a the report canvas but I'm having some issues.

Basically when I tell the report canvas to draw my TMetafile it appears on the finished file with what appears to be some formatting errors. However, I know that the TMetafile object in question has been correctly created and formatted because when I use my application's form canvas (which is also a TCanvas object) it renders the TMetafile flawlessly.

I've tried a number of things including:

- Using the Draw function of the TVCLCanvas and TPdfCanvas;
- Using the RenderMetafile of the TVCLCanvas;
- Changing the TVCLCanvas to a TMetafileCanvas;

To be clear, I can draw the metafile but it is rendered with errors. Has anyone had this issue? I'm a little lost to be honest.

P.S: Unrelated but if anyone knows of a good library that can help me generate tables (like an excel table) into a PDF document I'd be much obliged;

Offline

#2 2024-07-04 09:02:44

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

Re: Issue when frawwing metafile on canvas

How is the original metafile created?
Which commands do you use on the metafile?

Our renderer is not yet 100% accurate.
It works fine with simple metafile content, with text and drawings.
Complex transformations, clipping or transparency are not supported.

You can render simple tables using our TGdiPages report class.

Offline

#3 2024-07-05 13:26:12

RedVit
Member
Registered: 2024-07-04
Posts: 5

Re: Issue when frawwing metafile on canvas

The original metafile is created by another library I'm using that takes a LaTeX equation syntax and then returns it as a TMetafile.

It can also return it as a bitmap file which is rendered correctly on the canvas with no issues but is significantly heavier.

What seems to be happening is that the specific math symbols are not being recognized (like the integrals, infinite, stylized x an y symbols, etc...).
However, since the TVCLCanvas is a TCanvas (the same as the TForm canvas), I assumed that there would be no difference in the rendering between the both of them.

It seems like the symbols have the correct size (because I can select the "text" when visualizing the resulting PDF) but the rendering process doesn't know what to do with each symbol's "canvas".

Offline

#4 2024-07-05 15:54:02

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

Re: Issue when frawwing metafile on canvas

Could you post one or several EMF content to download?

Offline

#5 2024-07-08 09:03:45

RedVit
Member
Registered: 2024-07-04
Posts: 5

Re: Issue when frawwing metafile on canvas

Hi, sorry for the late reply.

Of course, here's WeTransfer link a zip with 2 EMF equations. I've confirmed they're correctly written.

https://we.tl/t-aSzY6gdC2D

Offline

#6 2024-07-08 13:39:28

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

Re: Issue when frawwing metafile on canvas

It is weird.

The glyph indexes supplied to the drawtext command do not exist in the Cambria Math font itself...
So TPdfFontTrueType.GetAndMarkGlyphAsUsed can't find anything to draw and fallback to 0.

If we fallback to the supplied glyph index... it seems to be displayed as expected!

Please try
https://github.com/synopse/mORMot2/commit/a899ded4

Offline

#7 2024-07-11 10:39:19

RedVit
Member
Registered: 2024-07-04
Posts: 5

Re: Issue when frawwing metafile on canvas

Hi, so it seems somewhat better. However the symbols being used are not the correct ones.

It seems like there might still be an indexing issue.

It's currently looking like this:
https://freeimage.host/i/dqxLXMQ

And it should look like this:
https://freeimage.host/i/dqxLilI

Note: This second image is what is drawn when I export the equation as a bitmap.

(Sorry for the delays, I can only reply from home because my office IP was banned automatically by the forum hmm)

Offline

#8 2024-07-24 13:51:28

RedVit
Member
Registered: 2024-07-04
Posts: 5

Re: Issue when frawwing metafile on canvas

Hi, have you had any progress with this issue?

We'd really like to know if this is an issue with the SynPDF library or the library that handles the equation metafile creation

Offline

Board footer

Powered by FluxBB