mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 08:08:07 +02:00
XFA - Implement usehref support
- attribute 'use' was already implemented but not usehref - in general, usehref should make reference to current document - add support for SOM expressions in use and usehref to search a node. - get prototype for all nodes if any.
This commit is contained in:
parent
e962d7787e
commit
11573ddd16
4 changed files with 158 additions and 50 deletions
|
@ -304,6 +304,56 @@ describe("XFAParser", function () {
|
|||
expect(font.extras.id).toEqual("id2");
|
||||
});
|
||||
|
||||
it("should parse a xfa document and apply some prototypes through usehref", 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">
|
||||
<subform>
|
||||
<proto>
|
||||
<draw name="foo">
|
||||
<font typeface="Foo" size="123pt" weight="bold" posture="italic">
|
||||
<fill>
|
||||
<color value="1,2,3"/>
|
||||
</fill>
|
||||
</font>
|
||||
</draw>
|
||||
</proto>
|
||||
<field>
|
||||
<font usehref=".#som($template.#subform.foo.#font)"/>
|
||||
</field>
|
||||
<field>
|
||||
<font usehref=".#som($template.#subform.foo.#font)" size="456pt" weight="bold" posture="normal">
|
||||
<fill>
|
||||
<color value="4,5,6"/>
|
||||
</fill>
|
||||
<extras id="id2"/>
|
||||
</font>
|
||||
</field>
|
||||
</subform>
|
||||
</template>
|
||||
</xdp:xdp>
|
||||
`;
|
||||
const root = new XFAParser().parse(xml)[$dump]();
|
||||
let font = root.template.subform.field[0].font;
|
||||
expect(font.typeface).toEqual("Foo");
|
||||
expect(font.overline).toEqual(0);
|
||||
expect(font.size).toEqual(123);
|
||||
expect(font.weight).toEqual("bold");
|
||||
expect(font.posture).toEqual("italic");
|
||||
expect(font.fill.color.value).toEqual({ r: 1, g: 2, b: 3 });
|
||||
expect(font.extras).toEqual(undefined);
|
||||
|
||||
font = root.template.subform.field[1].font;
|
||||
expect(font.typeface).toEqual("Foo");
|
||||
expect(font.overline).toEqual(0);
|
||||
expect(font.size).toEqual(456);
|
||||
expect(font.weight).toEqual("bold");
|
||||
expect(font.posture).toEqual("normal");
|
||||
expect(font.fill.color.value).toEqual({ r: 4, g: 5, b: 6 });
|
||||
expect(font.extras.id).toEqual("id2");
|
||||
});
|
||||
|
||||
it("should parse a xfa document with xhtml", function () {
|
||||
const xml = `
|
||||
<?xml version="1.0"?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue