1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Take the absolute value of the font size when the annotation contents is in xhtml (bug 1938087)

This commit is contained in:
Calixte Denizet 2024-12-18 17:00:45 +01:00
parent 8985d80aef
commit 723ee9bc8c
2 changed files with 43 additions and 1 deletions

View file

@ -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 = `
<?xml version="1.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<template xmlns="http://www.xfa.org/schema/xfa-template/3.3">
<subform name="root" mergeMode="matchTemplate">
<pageSet>
<pageArea>
<contentArea x="0pt" w="456pt" h="789pt"/>
<draw y="1pt" w="11pt" h="22pt" x="2pt">
<value>
<text>
<body xmlns="http://www.w3.org/1999/xhtml">
<p style="foo: bar; text-indent:0.5in; line-height:11px;font-size: -14.0pt; bar:foo;tab-stop: left 0.5in;">
The first line of this paragraph is indented a half-inch.<br/>
Successive lines are not indented.<br/>
This is the last line of the paragraph.<br/>
</p>
</body>
</text>
</value>
</draw>
</pageArea>
</pageSet>
</subform>
</template>
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
</xfa:data>
</xfa:datasets>
</xdp:xdp>
`;
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");
});
});