diff --git a/src/core/xfa/xhtml.js b/src/core/xfa/xhtml.js index 3e9847c7beb88..1c1eab989cfd5 100644 --- a/src/core/xfa/xhtml.js +++ b/src/core/xfa/xhtml.js @@ -94,7 +94,8 @@ const StyleMapping = new Map([ [ "font-size", (value, original) => { - value = original.fontSize = getMeasurement(value); + // The font size must be positive. + value = original.fontSize = Math.abs(getMeasurement(value)); return measureToString(0.99 * value); }, ], diff --git a/test/unit/xfa_tohtml_spec.js b/test/unit/xfa_tohtml_spec.js index e4284963926b0..615ba3c123d75 100644 --- a/test/unit/xfa_tohtml_spec.js +++ b/test/unit/xfa_tohtml_spec.js @@ -642,4 +642,45 @@ describe("XFAFactory", function () { expect(a.attributes.href).toEqual("https://github.com/allizom/pdf.js"); expect(a.attributes.newWindow).toEqual(false); }); + + it("should take the absolute value of the font size", async () => { + const xml = ` + + + + + + + + + + + + + The first line of this paragraph is indented a half-inch. + Successive lines are not indented. + This is the last line of the paragraph. + + + + + + + + + + + + + + + `; + const factory = new XFAFactory({ "xdp:xdp": xml }); + + expect(await factory.getNumPages()).toEqual(1); + + const pages = await factory.getPages(); + const p = searchHtmlNode(pages, "name", "p"); + expect(p.attributes.style.fontSize).toEqual("13.86px"); + }); });
+ The first line of this paragraph is indented a half-inch. + Successive lines are not indented. + This is the last line of the paragraph. +