mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Ensure that all necessary /Font resources are included when saving a WidgetAnnotation
-instance (issue 12294)
This patch contains a possible approach for fixing issue 12294, which compared to other PRs is purposely limited to the affected `WidgetAnnotation` code. As mentioned elsewhere, considering that we're (at least for now) trying to fix *one specific* case, I think that we should avoid modifying the `Dict` primitive[1] and/or avoid a solution that (indirectly) modifies an existing `Dict`-instance[2]. This patch simply fixes the issue at hand, since that seems easiest for now, and I'd suggest that we worry about a more general approach if/when that actually becomes necessary. Hence the solution implemented here, for `WidgetAnnotation`, is to simply use a combination of the local *and* AcroForm /DR resources during OperatorList-parsing to ensure that things work correctly regardless of where a particular /Font resource is found. For saving of form-data, on the other hand, we want to avoid increasing the file-size unnecessarily and need to be smarter than just merging all of the available resources. To achive this, a new `WidgetAnnotation._getSaveFieldResources` method will when necessary produce a combined resources `Dict` with only the minimum amount of data from the AcroForm /DR resources included. --- [1] You want to avoid anything that could cause the general `Dict` implementation to become slower, or more complex, just for handling an edge-case in my opinion. [2] If an existing `Dict`-instance is modified unexpectedly, that could very easily lead to problems elsewhere since e.g. `Dict`-instances created during parsing are not expected to be changed.
This commit is contained in:
parent
741ce4f7fc
commit
c992b8e460
3 changed files with 81 additions and 15 deletions
1
test/pdfs/issue12294.pdf.link
Normal file
1
test/pdfs/issue12294.pdf.link
Normal file
|
@ -0,0 +1 @@
|
|||
https://web.archive.org/web/20200914130729/https://www.nta.go.jp/taxes/tetsuzuki/shinsei/annai/joyaku/annai/pdf2/250.pdf
|
|
@ -2780,6 +2780,18 @@
|
|||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue12294-print",
|
||||
"file": "pdfs/issue12294.pdf",
|
||||
"md5": "a0ac5e03be38b5fb7a7a615e30024b28",
|
||||
"rounds": 1,
|
||||
"lastPage": 1,
|
||||
"link": true,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"2795R": "氏 名 又 は 名 称 Full name"
|
||||
}
|
||||
},
|
||||
{ "id": "issue7598",
|
||||
"file": "pdfs/issue7598.pdf",
|
||||
"md5": "c5bc5a779bfcb4b234f853231b56cf60",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue