Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to create Optional Content Group (OCG) with weasyprint? #1238

Open
bolatuly opened this issue Oct 16, 2020 · 3 comments
Open
Labels
feature New feature that should be supported

Comments

@bolatuly
Copy link

Is it possible to create Optional Content Group (OCG), collection of graphics that can be made visible or
invisible dynamically, with weasyprint?

Chapter 8.11.2 in https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf

@liZe liZe added the feature New feature that should be supported label Oct 21, 2020
@liZe
Copy link
Member

liZe commented Oct 21, 2020

Hello!

No, it’s not possible (yet). But when we have our own PDF writer (you can follow #1232 if you want to get news about that), we’ll be able to add this feature.

@hiaselhans
Copy link

So, since #1770 is closed, i am joining here for discussion.

The reason i am looking into OCG support is that when converting SVG images, it would be really nice to preserve the document structure for later editing of the generated PDF.

I will try to get a deeper insight the next days. If you have useful resources for me, I'd be happy to have them at hand.

Thanks for the great lib!

@liZe
Copy link
Member

liZe commented Dec 3, 2022

I will try to get a deeper insight the next days. If you have useful resources for me, I'd be happy to have them at hand.

If you want to have a quick and dirty way to implement this, you can probably add some code here:

# Draw node children

It should be possible to add the OCG and OCMD dictionaries when the tag is g, and it could be useful to get this code working if you’re interested, even if we don’t merge it as-is.

As explained in #1770, the real challenge here comes after the proof of concept. As we don’t want to add these groupes unconditionally, and as the use cases will be different depending on the users needs, we have to provide a clean API that can let users do what they want where they want. To be honest, I don’t know how/if it’s possible to do this, other than letting users monkey-patch the current functions (that are not officially public). But if anyone has an idea, it’s the place to discuss about this topic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

3 participants