Issue rendering EMF files with PlayEnhMetaFile
a library to create/modify PDF documents using HDC/TCanvas
Brought to you by:
mc-zyx
I've been testing out the library and I found issues when trying to draw .emf files with PlayEnhMetaFile. Please see the image/code attached. The image is a simple circle, but it is not being drawn in the final PDF. Thought the image might be the issue, but I am able to render it on a simple desktop application.
Thanks!
There seem to be an issue with EMR_SELECTCLIPPATH. If I comment out the code in it, the image renders fine
Last edit: Don Perignon 2021-12-01
Thanks for a bug report and test data. If I recall correctly, the EMF uses world transformation matrix, which the litePDF doesn't work well with. It's a known limitation of the litePDF. I'll give this some testing when I find time and I'll update this report .
The problem was truly with the world transformation matrix, it scales and moves the content, but it was not applied when constructing the clip region. I added that in [r29].
Related
Commit: [r29]
I'm reopening this. The change for this broke a test case from the [#43].
Related
Tickets:
#43Could you give a try to this test build in your environment/with your data, please?
I reverted the previous commit and made different approach. The EMF file sets an "almost identity" world transformation matrix, which confuses the code. I made the code less strict about the values, considering matrix within 1e-2 as identity.
It's a known limitation of the litePDF, it doesn't work well with the world transformations.
Great! Its works.
Thanks for a quick test. I'd like to wait for Don's response too, in case his environment/data is different. The test .emf from the description seems to work properly here as well (I can see the circle in the resulting PDF).
I will make a new release (around) the next week, unless I'm proved of any bad side effects with the test dll.
I just made a 2.0.5.1 release with these changes.
I need to rethink the whole world transformation matrix situation, because what the Inkscape does (and EMF) is that it wants the drawing to be slightly smaller, which the litePDF currently ignores. The best would be to draw to the litePDF's HDC directly, not using the EMF as the intermediate format, whenever possible.
In any case, the world transformation matrix situation requires significant amount of time, not only for the coding, but also for the testing, because it will affect the core drawing routines of the litePDF, thus do not expect anything soon in this regard.
Many thanks. The DLL from sdk 2.0.5.1 still works.
I'm sorry for the delay! I've tested it and it works on my side. Thank you for helping with this :)
Cheers!