Tagged PDFs? #799
-
Is anyone able to generate tagged PDFs (essential for accessibility) with Browsershot/Puppeteer? I don't know if my brain is playing tricks on me, but I could swear that PDFs generated in the app I'm developing were found to be tagged by Acrobat, but now they're not. I saw an option for this in Puppeteer, but either I don't know how to apply it, or it doesn't work. I've also seen some discussions regarding Chromium support for tagged PDFs, but again, nothing that clearly indicated whether this actually works or how to get it to work. With all of these pieces of technology working together, which one is responsible for supporting this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Does adding the below flag to chromium work? Browsershot::html('Foo')
->addChromiumArguments([
'export-tagged-pdf',
]); Sources: https://spatie.be/docs/browsershot/v2/requirements#content-pass-custom-arguments-to-chromium |
Beta Was this translation helpful? Give feedback.
-
Thanks @ntaylor-86. No, it does not. I thought Chromium is supposed to generate tagged PDFs by default now. I don't know what's breaking this — Chromium, Puppeteer, Browsershot.... — but it's a real shame considering how essential tags are for PDF accessibility. And I'm surprised that no one has brought this up here previously. I can't be the only one concerned about generating tagged PDFs. |
Beta Was this translation helpful? Give feedback.
-
I just tested my local version of chrome using puppeteer (HeadlessChrome/105.0.5173.0); Which lines up with the version of Puppeteer I've got installed Using the Chromium Blog as an example, I got Browsershot to save the pdf. Browsershot::url('https://blog.chromium.org/2020/07/using-chrome-to-generate-more.html')->savePdf('ChromiumBlog.pdf'); I didn't know the best way to check if the pdf was tagged, I found Read PDF Metadata (https://www.pdfyeah.com/view-pdf-metadata/)
Looks like this version of Chromium is generating tags without any additional flags. |
Beta Was this translation helpful? Give feedback.
Give this a try.
Edit this file:
vendor/spatie/browsershot/src/Browsershot.php
Modify the
createPdfCommand()
method:and add the line
$command['options']['tagged'] = true;
e.g.