diff --git a/src/core/annotation.js b/src/core/annotation.js index d26ddeafbc1aa..cf1f742d75199 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -994,10 +994,13 @@ class WidgetAnnotation extends Annotation { data.defaultFieldValue = this._decodeFormValue(defaultFieldValue); data.alternativeText = stringToPDFString(dict.get("TU") || ""); - data.defaultAppearance = + const defaultAppearance = getInheritableProperty({ dict, key: "DA" }) || params.acroForm.get("DA") || ""; + data.defaultAppearance = isString(defaultAppearance) + ? defaultAppearance + : ""; const fieldType = getInheritableProperty({ dict, key: "FT" }); data.fieldType = isName(fieldType) ? fieldType.name : null; @@ -1282,6 +1285,15 @@ class WidgetAnnotation extends Annotation { const totalHeight = this.data.rect[3] - this.data.rect[1]; const totalWidth = this.data.rect[2] - this.data.rect[0]; + if (!this.data.defaultAppearance) { + // The DA is required and must be a string. + // If there is no font named Helvetica in the resource dictionary, + // the evaluator will fall back to a default font. + // Doing so prevents exceptions and allows saving/printing + // the file as expected. + this.data.defaultAppearance = "/Helvetica 0 Tf 0 g"; + } + const fontInfo = await this._getFontData(evaluator, task); const [font, fontName] = fontInfo; const fontSize = this._computeFontSize(...fontInfo, totalHeight); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index e4fca428adc0a..3433db76785a9 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -48,6 +48,7 @@ !issue6931_reduced.pdf !issue7580.pdf !issue7598.pdf +!issue12750.pdf !issue7665.pdf !issue7696.pdf !issue7835.pdf diff --git a/test/pdfs/issue12750.pdf b/test/pdfs/issue12750.pdf new file mode 100644 index 0000000000000..c4f5bd92ef64b Binary files /dev/null and b/test/pdfs/issue12750.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 1fd7bfa1d7ba9..800b2699fa661 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2779,6 +2779,18 @@ "link": true, "type": "eq" }, + { "id": "issue12750", + "file": "pdfs/issue12750.pdf", + "md5": "47a39ef5d6ae2e4f52887c477cfdfc9e", + "rounds": 1, + "type": "eq", + "print": true, + "annotationStorage": { + "12R": { + "value": "foobar" + } + } + }, { "id": "preistabelle-text", "file": "pdfs/preistabelle.pdf", "md5": "d2f0b2086160d4f3d325c79a5dc1fb4d",