1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00
calixteman 2021-02-11 03:30:37 -08:00 committed by GitHub
parent 3787bd41ef
commit 0479deef4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 623 additions and 2 deletions

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { $dump } from "../../src/core/xfa/xfa_object.js";
import { $dump, $getChildren, $text } from "../../src/core/xfa/xfa_object.js";
import { XFAParser } from "../../src/core/xfa/parser.js";
describe("XFAParser", function () {
@ -247,5 +247,38 @@ describe("XFAParser", function () {
};
expect(root[$dump]()).toEqual(expected);
});
it("should parse a xfa document with xhtml", function () {
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">
<extras>
<text>
<body xmlns="http://www.w3.org/1999/xhtml">
<p style="foo: bar; text-indent:0.5in; line-height:11px;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>
</extras>
</template>
</xdp:xdp>
`;
const root = new XFAParser().parse(xml)[$dump]();
const p = root.template.extras.text.$content[$getChildren]()[0];
expect(p.style).toEqual(
"text-indent:0.5in;line-height:11px;tab-stop:left 0.5in"
);
expect(p[$text]()).toEqual(
[
"The first line of this paragraph is indented a half-inch.\n",
"Successive lines are not indented.\n",
"This is the last line of the paragraph.\n",
].join("")
);
});
});
});