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

<mask> element not supported #148

Open
Alwinator opened this issue Feb 22, 2022 · 4 comments
Open

<mask> element not supported #148

Alwinator opened this issue Feb 22, 2022 · 4 comments

Comments

@Alwinator
Copy link

Alwinator commented Feb 22, 2022

I am using a pipeline that generates a PDF using asciidoctor-pdf. It looks roughly like this:

Many PDF documents > PDF to SVG converter > AsciiDoc with included SVG images > PDF file

On the last step, when asciidoctor-pdf generates the PDF I am getting the following error. Since asciidoctor-pdf is based on prawn-svg I think the error is referred to this repository.

The error in the logs:

asciidoctor: WARNING: problem encountered in image: /tmp/pre-build/writing/images/pre-documents/pdf2svg_status_report_2022_01_06/14.svg; Unknown tag 'mask'; ignoring

This is the SVG that is included in the asciidoctor file. On GitHub, it is rendered as it should. Download SVG

Input SVG / Expected output

14

This is a screenshot of the final PDF. As you can see, it has a weird black background that it should not have:

Actual Output

image

I am not sure what the problem is, but I thought maybe the converter generates "newer" PDFs than prawn-pdf supports, what do you think?

@mogest
Copy link
Owner

mogest commented Feb 22, 2022

Hi @Alwinator, thanks for the report. prawn-svg doesn't handle mask, and it probably should since it's part of the svg 1.1 spec. It's the first time I've come across it!

The SVG you have there is very strange, though. It has two 2048x2048 PNG images in it, one of them being the icon you see above in the prawn-svg output (the blue icon with a black background), and the other being identical but using white instead of blue and used as a mask on the first image so that it doesn't draw its black background. Given that it could be expressed as a simple path that is not terribly good!

I would like to implement mask at some point so I'll leave this issue open, but perhaps you could look at your processing chain for a solution too. As a result of the embedded PNGs, these will be huge PDF files for what is a quite a simple drawing.

@mogest mogest changed the title Unknown tag 'mask'; ignoring <mask> element not supported Feb 22, 2022
@Alwinator
Copy link
Author

@mogest Thank you! I have just analysed the SVG file and, as you mentioned, it is really weird. Especially, because the original PDF is vector graphic only and does not include a PNG. I will take a more detailed look at the other parts of my pipeline.

@Alwinator
Copy link
Author

@mogest I have tried many other PDF to SVG converters and unfortunately, all other converters are generating SVGs with <mask> tags. I would appreciate it a lot if you could implement it if you have time. Thank you very much in advance!

@mogest
Copy link
Owner

mogest commented Feb 3, 2024

I've made an implementation of in the mask branch. It works with the example in the SVG spec, but does not appear to be working with the above SVG—perhaps because it uses an image to create the mask. Will require more investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants