mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[api-minor] Implement basic support for OptionalContent Usage
dicts (issue 5764, bug 1826783)
The following are some highlights of this patch: - In the Worker we only extract a *subset* of the potential contents of the `Usage` dictionary, to avoid having to implement/test a bunch of code that'd be completely unused in the viewer. - In order to still allow the user to *manually* override the default visible layers in the viewer, the viewable/printable state is purposely *not* enforced during initialization in the `OptionalContentConfig` constructor. - Printing will now always use the *default* visible layers, rather than using the same state as the viewer (as was the case previously). This ensures that the printing-output will correctly take the `Usage` dictionary into account, and in practice toggling of visible layers rarely seem to be necessary except in the viewer itself (if at all).[1] --- [1] In the unlikely case that it'd ever be deemed necessary to support fine-grained control of optional content visibility during printing, some new (additional) UI would likely be needed to support that case.
This commit is contained in:
parent
e647311a89
commit
3c78ff5fb0
13 changed files with 186 additions and 62 deletions
|
@ -684,7 +684,9 @@ class Driver {
|
|||
}
|
||||
|
||||
task.pdfDoc = doc;
|
||||
task.optionalContentConfigPromise = doc.getOptionalContentConfig();
|
||||
task.optionalContentConfigPromise = doc.getOptionalContentConfig({
|
||||
intent: task.print ? "print" : "display",
|
||||
});
|
||||
|
||||
if (task.optionalContent) {
|
||||
const entries = Object.entries(task.optionalContent),
|
||||
|
|
1
test/pdfs/bug1826783.pdf.link
Normal file
1
test/pdfs/bug1826783.pdf.link
Normal file
|
@ -0,0 +1 @@
|
|||
https://bugzilla.mozilla.org/attachment.cgi?id=9327375
|
|
@ -4016,6 +4016,23 @@
|
|||
"lastPage": 5,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "bug1826783-display",
|
||||
"file": "pdfs/bug1826783.pdf",
|
||||
"md5": "93e706efee15dd7b32d32d66f15a3ea2",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "bug1826783-print",
|
||||
"file": "pdfs/bug1826783.pdf",
|
||||
"md5": "93e706efee15dd7b32d32d66f15a3ea2",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq",
|
||||
"print": true
|
||||
},
|
||||
{
|
||||
"id": "issue8586",
|
||||
"file": "pdfs/issue8586.pdf",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue