mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-11-30 16:37:18 +01:00
Set the XFA fonts when the AcroForm has no fonts in /DR
`#loadXfaFonts` returned before `setFonts` when /DR or /DR /Font was missing, and the layout then threw at the first text it measured. With an empty font dictionary, pdf.js loads a substitute for each font the form uses, as it does for a font missing from /DR. The PDF in #13647 has no /DR either.
This commit is contained in:
@@ -1382,15 +1382,18 @@ class PDFDocument {
|
||||
if (!acroForm) {
|
||||
return;
|
||||
}
|
||||
const resources = await acroForm.getAsync("DR");
|
||||
if (!(resources instanceof Dict)) {
|
||||
return;
|
||||
// Without any fonts in /DR, the XFA layout still needs a font finder:
|
||||
// the fonts it uses are then all loaded as missing fonts.
|
||||
let resources = await acroForm.getAsync("DR");
|
||||
if (resources instanceof Dict) {
|
||||
await ObjectLoader.load(resources, ["Font"], this.xref);
|
||||
} else {
|
||||
resources = Dict.empty;
|
||||
}
|
||||
await ObjectLoader.load(resources, ["Font"], this.xref);
|
||||
|
||||
const fontRes = resources.get("Font");
|
||||
let fontRes = resources.get("Font");
|
||||
if (!(fontRes instanceof Dict)) {
|
||||
return;
|
||||
fontRes = Dict.empty;
|
||||
}
|
||||
|
||||
const options = Object.assign(
|
||||
|
||||
@@ -638,6 +638,7 @@
|
||||
!issue20324.pdf
|
||||
!bug1815476.pdf
|
||||
!issue16021.pdf
|
||||
!xfa_without_dr_fonts.pdf
|
||||
!bug1770750.pdf
|
||||
!issue19971.pdf
|
||||
!issue16063.pdf
|
||||
|
||||
Binary file not shown.
@@ -8000,6 +8000,15 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "xfa_without_dr_fonts",
|
||||
"file": "pdfs/xfa_without_dr_fonts.pdf",
|
||||
"md5": "80d3a2f5eb7332010ca35d33348d4011",
|
||||
"rounds": 1,
|
||||
"enableXfa": true,
|
||||
"type": "eq",
|
||||
"about": "Pure XFA form without fonts in the AcroForm /DR."
|
||||
},
|
||||
{
|
||||
"id": "issue3207",
|
||||
"file": "pdfs/issue3207r.pdf",
|
||||
|
||||
Reference in New Issue
Block a user