mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.76k stars 10.03k forks source link

[Bug]: PDF layer visibility on printing #18954

Open user-kh opened 1 month ago

user-kh commented 1 month ago

Attach (recommended) or Link to PDF file

Test.pdf

Web browser and its version

Firefox

Operating system and its version

every

PDF.js version

every

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

User essigwurst discovered the error:

https://connect.mozilla.org/t5/ideas/built-in-pdf-editor-layer-visibility-on-printing/idi-p/57362

What is the expected behavior?

If a layer has been deactivated, I also expect that it will not be printed.

What went wrong?

`There is a PDF feature, which are called "layers". I see this as an advantage, that Firefox supports those, and also supports enabling / disabling (set visibility) them when a PDF file is opened in the browser itself.

However, when someone want to print this file (with some layers enabled and some disabled), it would always print everything (all layers enabled / set to visible), therefore it would be good, if the current layer settings would be also applied when someone prints the document.`

layers

Link to a viewer

No response

Additional context

No response

Snuffleupagus commented 1 month ago

Attach (recommended) or Link to PDF file

layers

Note: As mention in the issue template, please actually attach the PDF file under this heading (and not a screen-shot).

As mentioned in https://github.com/mozilla/pdf.js/pull/17726#issue-2152763340, see the third point, this isn't entirely trivial to implement since we also need to take the Usage dictionary into account when printing.

user-kh commented 1 month ago

Thanks for the tip. I have attached an example. I use this feature a lot. It would be great, if the developers could include this feature.

Maybe an idea: Could you perhaps add a 'print media query' as a workaround so that you can use the browser printer and it prints the PDF correctly?

GitHubRulesOK commented 4 weeks ago

Just a COMMENT that for PDF there are separate yet inter-related layer control FLAGS for print and view here is the OP file correctly set for layer "no print" Test (hiden print layer).pdf

Viewer control On Off is as expected. Shown by the layer controls

image

BOTH LAYERS ON but print flag OFF in PDF works as per standards the no print layer is correctly not printed by PDF.js

image image

image