You are not logged in.
Pages: 1
Hello everyone,
I can't seem to find a way to use optional content (layers) when drawing with VCLCanvas.
All content drawn in VCLCanvas is always saved outside any optional content, regardless of the use of BeginMarkedContent/EndMarkedContent.
Am I missing anything? Any pointer on the correct way to use it?
Thanks,
Regards,
Padule
Offline
You are right: BeginMarkedContent is at the PDF canvas level, and is not available from the VCL canvas.
It is technically possible to enhance the library by adding a new TPdfGdiComment kind of custom message, and a GdiCommentMarkContent() generation function.
But it is not yet supported.
You are free to propose a pull request for this.
Offline
Thank you for your prompt reply, and for pointing out a possible solution.
I specifically need this for a project, so if I don't find an alternative I will probably try to implement it in SynPDF myself some time in the next months.
If so, I will contribute with a pull request.
Thank you.
Offline
You could take a look at https://github.com/synopse/mORMot2/commit/196f94c6
Offline
Hello ab, I gave a look, interesting solution.
Am I wrong or it creates a new group at each call? I would much prefer to pass the TPdfOptionalContentGroup object that references the group, maybe saving in the comment the pdf group object id instead of the title.
Offline
The problem is that the TPdfOptionalContentGroup instance is local to the page PDF canvas, and we don't have any page PDF context at the level of the VCL canvas.
We may enhance the code to reuse an existing GroupTitle in the page.
Offline
Since the CreateOptionalContentGroup is a method of the TPdfDocument class I thought it was global to the document and not local to the page.
If every page has its own layers then it is not useful for my project, even though I am pretty sure the PDF specification supports layers that span through multiple pages.
Offline
You are right.
We can safely use a group instance for the whole current document.
Please try https://github.com/synopse/mORMot2/commit/9472f88c
Offline
Looks great *thumbs up*.
About mormot.ui.pdf.pas, can it be used standalone? Otherwise I will port the modifications to SynPDF.
Offline
No, you need other units from mORMot 2.
Note that SynPDF is not stand-alone since a lot of time, and trying to extract it from mORMot 1 tends to make confusion and compillation errors if you want to use mORMot otherwise...
So I would suggest to use mormot.ui.pdf.pas from the whole mORMot 2 framework.
The compiler will compile only what is needed for your project. The DB, ORM and such is clearly distinct from the PDF unit.
Offline
Thank you ab, I'll give a look at the framework then.
Offline
Hello again ab,
Regarding the latest commit above, I spotted a bug that doesn't mark the end of the optional content.
The GdiComment for pgcEndMarkContent has a size of 1 (just the identifier) while in the EnumEMFFunc for the EMR_GDICOMMENT checks the data size to be >1, thus failing in case of the pgcEndMarkContent. (mortmot.ui.pdf.pas ~line 10939)
I hope my explanation is clear, if you need further info let me know.
Last edited by padule (2023-07-25 12:30:59)
Offline
Offline
Yes, same fix I did on my side
Offline
Pages: 1