pdfdancer-client-typescript 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -27
- package/dist/__tests__/e2e/pdf-assertions.d.ts +20 -3
- package/dist/__tests__/e2e/pdf-assertions.d.ts.map +1 -1
- package/dist/__tests__/e2e/pdf-assertions.js +151 -86
- package/dist/__tests__/e2e/pdf-assertions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +106 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +195 -2
- package/dist/models.js.map +1 -1
- package/dist/paragraph-builder.d.ts +2 -2
- package/dist/paragraph-builder.d.ts.map +1 -1
- package/dist/paragraph-builder.js +10 -2
- package/dist/paragraph-builder.js.map +1 -1
- package/dist/pdfdancer_v1.d.ts +41 -4
- package/dist/pdfdancer_v1.d.ts.map +1 -1
- package/dist/pdfdancer_v1.js +198 -20
- package/dist/pdfdancer_v1.js.map +1 -1
- package/dist/types.d.ts +15 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +41 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/e2e/acroform.test.ts +13 -0
- package/src/__tests__/e2e/create-new.test.ts +133 -0
- package/src/__tests__/e2e/form_x_object.test.ts +8 -0
- package/src/__tests__/e2e/image.test.ts +30 -18
- package/src/__tests__/e2e/line.test.ts +33 -6
- package/src/__tests__/e2e/page.test.ts +4 -0
- package/src/__tests__/e2e/paragraph.test.ts +29 -2
- package/src/__tests__/e2e/path.test.ts +8 -0
- package/src/__tests__/e2e/pdf-assertions.ts +164 -73
- package/src/__tests__/url-builder.test.ts +44 -0
- package/src/index.ts +8 -1
- package/src/models.ts +255 -1
- package/src/paragraph-builder.ts +13 -5
- package/src/pdfdancer_v1.ts +277 -28
- package/src/types.ts +55 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FormFieldRef, ObjectRef, ObjectType, Position, TextObjectRef } from "./models";
|
|
1
|
+
import { Color, CommandResult, FormFieldRef, ObjectRef, ObjectType, Position, TextObjectRef } from "./models";
|
|
2
2
|
import { PDFDancer } from "./pdfdancer_v1";
|
|
3
3
|
import { ParagraphBuilder } from "./paragraph-builder";
|
|
4
4
|
interface PDFDancerInternals {
|
|
5
5
|
delete(objectRef: ObjectRef): Promise<boolean>;
|
|
6
6
|
move(objectRef: ObjectRef, position: Position): Promise<boolean>;
|
|
7
7
|
changeFormField(formFieldRef: FormFieldRef, value: string): Promise<boolean>;
|
|
8
|
-
modifyTextLine(objectRef: ObjectRef, newText: string): Promise<
|
|
8
|
+
modifyTextLine(objectRef: ObjectRef, newText: string): Promise<CommandResult>;
|
|
9
9
|
}
|
|
10
10
|
export declare class BaseObject<TRef extends ObjectRef = ObjectRef> {
|
|
11
11
|
_client: PDFDancer;
|
|
@@ -44,6 +44,12 @@ export declare class ParagraphObject extends BaseObject<TextObjectRef> {
|
|
|
44
44
|
private color;
|
|
45
45
|
static fromRef(_client: PDFDancer, objectRef: TextObjectRef): ParagraphObject;
|
|
46
46
|
edit(): ParagraphBuilder;
|
|
47
|
+
objectRef(): TextObjectRef;
|
|
48
|
+
getText(): string | undefined;
|
|
49
|
+
getFontName(): string | undefined;
|
|
50
|
+
getFontSize(): number | undefined;
|
|
51
|
+
getColor(): Color | undefined;
|
|
52
|
+
getChildren(): TextObjectRef[] | undefined;
|
|
47
53
|
private setFontName;
|
|
48
54
|
private setFontSize;
|
|
49
55
|
private setLineSpacings;
|
|
@@ -66,6 +72,12 @@ export declare class TextLineObject extends BaseObject<TextObjectRef> {
|
|
|
66
72
|
private setText;
|
|
67
73
|
private setChildren;
|
|
68
74
|
private setColor;
|
|
75
|
+
objectRef(): TextObjectRef;
|
|
76
|
+
getText(): string | undefined;
|
|
77
|
+
getFontName(): string | undefined;
|
|
78
|
+
getFontSize(): number | undefined;
|
|
79
|
+
getColor(): Color | undefined;
|
|
80
|
+
getChildren(): TextObjectRef[] | undefined;
|
|
69
81
|
}
|
|
70
82
|
declare class TextLineBuilder {
|
|
71
83
|
private _text;
|
|
@@ -74,7 +86,7 @@ declare class TextLineBuilder {
|
|
|
74
86
|
private _internals;
|
|
75
87
|
constructor(client: PDFDancer, objectRef: ObjectRef);
|
|
76
88
|
text(newText: string): this;
|
|
77
|
-
apply(): Promise<
|
|
89
|
+
apply(): Promise<CommandResult>;
|
|
78
90
|
}
|
|
79
91
|
export {};
|
|
80
92
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAGrD,UAAU,kBAAkB;IACxB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjE,eAAe,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7E,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACjF;AAED,qBAA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AM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;IAMnD,IAAI,CAAC,OAAO,EAAE,MAAM;IAKd,KAAK;CAOd"}
|
package/dist/types.js
CHANGED
|
@@ -72,6 +72,24 @@ class ParagraphObject extends BaseObject {
|
|
|
72
72
|
edit() {
|
|
73
73
|
return new paragraph_builder_1.ParagraphBuilder(this._client, this.ref());
|
|
74
74
|
}
|
|
75
|
+
objectRef() {
|
|
76
|
+
return this.ref();
|
|
77
|
+
}
|
|
78
|
+
getText() {
|
|
79
|
+
return this.text;
|
|
80
|
+
}
|
|
81
|
+
getFontName() {
|
|
82
|
+
return this.fontName;
|
|
83
|
+
}
|
|
84
|
+
getFontSize() {
|
|
85
|
+
return this.fontSize;
|
|
86
|
+
}
|
|
87
|
+
getColor() {
|
|
88
|
+
return this.color;
|
|
89
|
+
}
|
|
90
|
+
getChildren() {
|
|
91
|
+
return this.children;
|
|
92
|
+
}
|
|
75
93
|
setFontName(fontName) {
|
|
76
94
|
this.fontName = fontName;
|
|
77
95
|
}
|
|
@@ -125,6 +143,24 @@ class TextLineObject extends BaseObject {
|
|
|
125
143
|
setColor(color) {
|
|
126
144
|
this.color = color;
|
|
127
145
|
}
|
|
146
|
+
objectRef() {
|
|
147
|
+
return this.ref();
|
|
148
|
+
}
|
|
149
|
+
getText() {
|
|
150
|
+
return this.text;
|
|
151
|
+
}
|
|
152
|
+
getFontName() {
|
|
153
|
+
return this.fontName;
|
|
154
|
+
}
|
|
155
|
+
getFontSize() {
|
|
156
|
+
return this.fontSize;
|
|
157
|
+
}
|
|
158
|
+
getColor() {
|
|
159
|
+
return this.color;
|
|
160
|
+
}
|
|
161
|
+
getChildren() {
|
|
162
|
+
return this.children;
|
|
163
|
+
}
|
|
128
164
|
}
|
|
129
165
|
exports.TextLineObject = TextLineObject;
|
|
130
166
|
class TextLineBuilder {
|
|
@@ -138,7 +174,11 @@ class TextLineBuilder {
|
|
|
138
174
|
return this;
|
|
139
175
|
}
|
|
140
176
|
async apply() {
|
|
141
|
-
|
|
177
|
+
const result = await this._internals.modifyTextLine(this._objectRef, this._text);
|
|
178
|
+
if (result.warning) {
|
|
179
|
+
process.stderr.write(`WARNING: ${result.warning}\n`);
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
142
182
|
}
|
|
143
183
|
}
|
|
144
184
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,qCAA4G;AAE5G,2DAAqD;AAarD,MAAa,UAAU;IASnB,YAAY,MAAiB,EAAE,UAAkB,EAAE,IAAgB,EAAE,QAAkB;QACnF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAwC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9C,CAAC;IAES,GAAG;QACT,OAAO,IAAI,kBAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAS,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,CAAS;QAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,iBAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAU,EAAE,CAAC,EAAE,CAAC,CAAC,CAA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AAC;CACJ;AAxED,wCAwEC;AAGD,MAAM,eAAe;IAOjB,YAAY,MAAiB,EAAE,SAAoB;QAC/C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAwC,CAAC;IACpE,CAAC;IAED,IAAI,CAAC,OAAe;QAChB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAM,CAAC,CAAC;QAClF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {PDFDancer} from '../../index';
|
|
6
6
|
import {requireEnvAndFixture} from './test-helpers';
|
|
7
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
7
8
|
|
|
8
9
|
describe('AcroForm Fields E2E Tests (v2 API)', () => {
|
|
9
10
|
|
|
@@ -33,6 +34,9 @@ describe('AcroForm Fields E2E Tests (v2 API)', () => {
|
|
|
33
34
|
expect(firstForm).toHaveLength(1);
|
|
34
35
|
expect(firstForm[0].type).toBe('RADIO_BUTTON');
|
|
35
36
|
expect(firstForm[0].internalId).toBe('FORM_FIELD_000008');
|
|
37
|
+
|
|
38
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
39
|
+
await assertions.assertNumberOfFormFields(10);
|
|
36
40
|
});
|
|
37
41
|
|
|
38
42
|
test('delete form fields', async () => {
|
|
@@ -50,6 +54,9 @@ describe('AcroForm Fields E2E Tests (v2 API)', () => {
|
|
|
50
54
|
for (const f of remaining) {
|
|
51
55
|
expect(f.internalId).not.toBe(toDelete.internalId);
|
|
52
56
|
}
|
|
57
|
+
|
|
58
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
59
|
+
await assertions.assertNumberOfFormFields(9);
|
|
53
60
|
});
|
|
54
61
|
|
|
55
62
|
test('move form field', async () => {
|
|
@@ -70,6 +77,9 @@ describe('AcroForm Fields E2E Tests (v2 API)', () => {
|
|
|
70
77
|
fields = await pdf.page(0).selectFormFieldsAt(30, 40);
|
|
71
78
|
expect(fields).toHaveLength(1);
|
|
72
79
|
expect(fields[0].internalId).toBe(field.internalId);
|
|
80
|
+
|
|
81
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
82
|
+
await assertions.assertNumberOfFormFields(10);
|
|
73
83
|
});
|
|
74
84
|
|
|
75
85
|
test('edit form fields', async () => {
|
|
@@ -91,5 +101,8 @@ describe('AcroForm Fields E2E Tests (v2 API)', () => {
|
|
|
91
101
|
field = fields[0];
|
|
92
102
|
expect(field.name).toBe('firstName');
|
|
93
103
|
expect(field.value).toBe('Donald Duck');
|
|
104
|
+
|
|
105
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
106
|
+
await assertions.assertNumberOfFormFields(10);
|
|
94
107
|
});
|
|
95
108
|
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E tests for creating new PDF documents
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Color, Orientation, PDFDancer, StandardFonts} from '../../index';
|
|
6
|
+
import {getBaseUrl, readToken, serverUp} from './test-helpers';
|
|
7
|
+
import {expectWithin} from '../assertions';
|
|
8
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
9
|
+
|
|
10
|
+
describe('Create New PDF E2E Tests', () => {
|
|
11
|
+
let baseUrl: string;
|
|
12
|
+
let token: string;
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
baseUrl = getBaseUrl();
|
|
16
|
+
const tokenValue = readToken();
|
|
17
|
+
|
|
18
|
+
if (!await serverUp(baseUrl)) {
|
|
19
|
+
throw new Error(`PDFDancer server not reachable at ${baseUrl}; set PDFDANCER_BASE_URL or start server`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!tokenValue) {
|
|
23
|
+
throw new Error('PDFDANCER_TOKEN not set and no token file found; set env or place jwt-token-*.txt in repo');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
token = tokenValue;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const expectPdfSignature = (bytes: Uint8Array) => {
|
|
30
|
+
expect(bytes.length).toBeGreaterThan(4);
|
|
31
|
+
const signature = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3]);
|
|
32
|
+
expect(signature).toBe('%PDF');
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
test('create new PDF with defaults', async () => {
|
|
36
|
+
const client = await PDFDancer.new(undefined, token, baseUrl);
|
|
37
|
+
|
|
38
|
+
const pages = await client.pages();
|
|
39
|
+
expect(pages).toHaveLength(1);
|
|
40
|
+
|
|
41
|
+
const bytes = await client.getBytes();
|
|
42
|
+
expectPdfSignature(bytes);
|
|
43
|
+
|
|
44
|
+
const assertions = await PDFAssertions.create(client);
|
|
45
|
+
await assertions.assertTotalNumberOfElements(0);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('create new PDF with custom params', async () => {
|
|
49
|
+
const client = await PDFDancer.new(
|
|
50
|
+
{
|
|
51
|
+
pageSize: 'A4',
|
|
52
|
+
orientation: Orientation.LANDSCAPE,
|
|
53
|
+
initialPageCount: 3
|
|
54
|
+
},
|
|
55
|
+
token,
|
|
56
|
+
baseUrl
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const pages = await client.pages();
|
|
60
|
+
expect(pages).toHaveLength(3);
|
|
61
|
+
|
|
62
|
+
const assertions = await PDFAssertions.create(client);
|
|
63
|
+
await assertions.assertTotalNumberOfElements(0);
|
|
64
|
+
await assertions.assertPageCount(3);
|
|
65
|
+
for (let index = 0; index < pages.length; index++) {
|
|
66
|
+
await assertions.assertPageDimension(842.0, 595.0, undefined, index);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('create new PDF with string params', async () => {
|
|
71
|
+
const client = await PDFDancer.new(
|
|
72
|
+
{
|
|
73
|
+
pageSize: 'LETTER',
|
|
74
|
+
orientation: Orientation.PORTRAIT,
|
|
75
|
+
initialPageCount: 2
|
|
76
|
+
},
|
|
77
|
+
token,
|
|
78
|
+
baseUrl
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const pages = await client.pages();
|
|
82
|
+
expect(pages).toHaveLength(2);
|
|
83
|
+
|
|
84
|
+
const assertions = await PDFAssertions.create(client);
|
|
85
|
+
await assertions.assertTotalNumberOfElements(0);
|
|
86
|
+
await assertions.assertPageCount(2);
|
|
87
|
+
for (let index = 0; index < pages.length; index++) {
|
|
88
|
+
await assertions.assertPageDimension(612.0, 792.0, Orientation.PORTRAIT, index);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('create new PDF add content and verify placement', async () => {
|
|
93
|
+
const client = await PDFDancer.new(undefined, token, baseUrl);
|
|
94
|
+
|
|
95
|
+
await client.page(0)
|
|
96
|
+
.newParagraph()
|
|
97
|
+
.text('Hello from blank PDF')
|
|
98
|
+
.font(StandardFonts.COURIER_BOLD_OBLIQUE, 9)
|
|
99
|
+
.color(new Color(0, 255, 0))
|
|
100
|
+
.at(100, 201.5)
|
|
101
|
+
.apply();
|
|
102
|
+
|
|
103
|
+
const paragraphs = await client.selectParagraphs();
|
|
104
|
+
expect(paragraphs).toHaveLength(1);
|
|
105
|
+
const paragraph = paragraphs[0];
|
|
106
|
+
expect(paragraph.getText()).toContain('Hello from blank PDF');
|
|
107
|
+
expect(paragraph.getFontName()).toBe(StandardFonts.COURIER_BOLD_OBLIQUE);
|
|
108
|
+
expectWithin(paragraph.getFontSize(), 9, 1e-6);
|
|
109
|
+
expect(paragraph.getColor()).toEqual(new Color(0, 255, 0));
|
|
110
|
+
|
|
111
|
+
expectWithin(paragraph.position.getX()!, 100, 1e-6);
|
|
112
|
+
expectWithin(paragraph.position.getY()!, 201.5, 1e-6);
|
|
113
|
+
|
|
114
|
+
const textLines = await (await client.pages())[0].selectTextLines();
|
|
115
|
+
expect(textLines).toHaveLength(1);
|
|
116
|
+
expect(textLines[0].getText()).toContain('Hello from blank PDF');
|
|
117
|
+
|
|
118
|
+
const assertions = await PDFAssertions.create(client);
|
|
119
|
+
await assertions.assertPageCount(1);
|
|
120
|
+
await assertions.assertTotalNumberOfElements(2);
|
|
121
|
+
await assertions.assertParagraphIsAt('Hello from blank PDF', 100, 201.5);
|
|
122
|
+
await assertions.assertTextHasFont('Hello from blank PDF', StandardFonts.COURIER_BOLD_OBLIQUE, 9);
|
|
123
|
+
await assertions.assertTextHasColor('Hello from blank PDF', new Color(0, 255, 0));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('create new PDF rejects invalid page count', async () => {
|
|
127
|
+
await expect(PDFDancer.new(
|
|
128
|
+
{initialPageCount: 0},
|
|
129
|
+
token,
|
|
130
|
+
baseUrl
|
|
131
|
+
)).rejects.toThrow('Initial page count must be at least 1');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import {PDFDancer} from '../../index';
|
|
7
7
|
import {createTempPath, requireEnvAndFixture} from './test-helpers';
|
|
8
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
8
9
|
|
|
9
10
|
describe('Form E2E Tests (v2 API)', () => {
|
|
10
11
|
|
|
@@ -32,6 +33,10 @@ describe('Form E2E Tests (v2 API)', () => {
|
|
|
32
33
|
|
|
33
34
|
// Cleanup
|
|
34
35
|
fs.unlinkSync(outPath);
|
|
36
|
+
|
|
37
|
+
// No additional assertions beyond the direct API checks to avoid
|
|
38
|
+
// relying on backend enumerations that may omit form XObjects in the
|
|
39
|
+
// reopened document.
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
test('find form by position', async () => {
|
|
@@ -46,5 +51,8 @@ describe('Form E2E Tests (v2 API)', () => {
|
|
|
46
51
|
forms = await pdf.page(0).selectFormsAt(321, 601);
|
|
47
52
|
expect(forms).toHaveLength(1);
|
|
48
53
|
expect(forms[0].internalId).toBe('FORM_000005');
|
|
54
|
+
|
|
55
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
56
|
+
await assertions.assertNumberOfFormXObjects(0);
|
|
49
57
|
});
|
|
50
58
|
});
|
|
@@ -6,6 +6,7 @@ import * as fs from 'fs';
|
|
|
6
6
|
import {PDFDancer} from '../../index';
|
|
7
7
|
import {createTempPath, getImagePath, requireEnvAndFixture} from './test-helpers';
|
|
8
8
|
import {expectWithin} from '../assertions';
|
|
9
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
9
10
|
|
|
10
11
|
describe('Image E2E Tests (v2 API)', () => {
|
|
11
12
|
|
|
@@ -26,21 +27,25 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
26
27
|
const pdf = await PDFDancer.open(pdfData, token, baseUrl, 30000);
|
|
27
28
|
|
|
28
29
|
const images = await pdf.selectImages();
|
|
30
|
+
expect(images).toHaveLength(3);
|
|
29
31
|
for (const img of images) {
|
|
30
32
|
await img.delete();
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
expect(remaining).toHaveLength(0);
|
|
35
|
+
expect(await pdf.selectImages()).toHaveLength(0);
|
|
35
36
|
|
|
36
37
|
const outPath = createTempPath('deleteImage.pdf');
|
|
37
38
|
const outData = await pdf.getBytes();
|
|
38
39
|
fs.writeFileSync(outPath, outData);
|
|
39
|
-
|
|
40
40
|
expect(fs.existsSync(outPath)).toBe(true);
|
|
41
41
|
expect(fs.statSync(outPath).size).toBeGreaterThan(0);
|
|
42
|
-
|
|
43
42
|
fs.unlinkSync(outPath);
|
|
43
|
+
|
|
44
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
45
|
+
const pages = await pdf.pages();
|
|
46
|
+
for (const page of pages) {
|
|
47
|
+
await assertions.assertNumberOfImages(0, page.position.pageIndex);
|
|
48
|
+
}
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
test('move image', async () => {
|
|
@@ -50,14 +55,26 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
50
55
|
const images = await pdf.selectImages();
|
|
51
56
|
const image = images[2];
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
const originalX = image.position.boundingRect?.x!;
|
|
59
|
+
const originalY = image.position.boundingRect?.y!;
|
|
60
|
+
const pageIndex = image.position.pageIndex!;
|
|
61
|
+
|
|
62
|
+
expectWithin(originalX, 54, 0.5);
|
|
63
|
+
expectWithin(originalY, 300, 1);
|
|
64
|
+
expect(pageIndex).toBe(11);
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
const newX = 500.1;
|
|
67
|
+
const newY = 600.1;
|
|
68
|
+
await image.moveTo(newX, newY);
|
|
57
69
|
|
|
58
|
-
const moved =
|
|
59
|
-
|
|
60
|
-
expectWithin(moved.position.boundingRect?.
|
|
70
|
+
const moved = await pdf.page(pageIndex).selectImagesAt(newX, newY);
|
|
71
|
+
expect(moved).toHaveLength(1);
|
|
72
|
+
expectWithin(moved[0].position.boundingRect?.x, newX, 0.05);
|
|
73
|
+
expectWithin(moved[0].position.boundingRect?.y, newY, 0.05);
|
|
74
|
+
|
|
75
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
76
|
+
await assertions.assertImageAt(newX, newY, pageIndex);
|
|
77
|
+
await assertions.assertNoImageAt(originalX, originalY, pageIndex);
|
|
61
78
|
});
|
|
62
79
|
|
|
63
80
|
test('find image by position', async () => {
|
|
@@ -89,13 +106,8 @@ describe('Image E2E Tests (v2 API)', () => {
|
|
|
89
106
|
const after = await pdf.selectImages();
|
|
90
107
|
expect(after).toHaveLength(4);
|
|
91
108
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const added = page6Images[0];
|
|
96
|
-
expect(added.position.pageIndex).toBe(6);
|
|
97
|
-
expect(added.internalId).toBe('IMAGE_000004');
|
|
98
|
-
expectWithin(added.position.boundingRect?.x, 50.1, 0.05);
|
|
99
|
-
expectWithin(added.position.boundingRect?.y, 98.0, 0.05);
|
|
109
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
110
|
+
await assertions.assertImageAt(50.1, 98.0, 6);
|
|
111
|
+
await assertions.assertNumberOfImages(1, 6);
|
|
100
112
|
});
|
|
101
113
|
});
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as fs from 'fs';
|
|
6
|
-
import {PDFDancer} from '../../index';
|
|
6
|
+
import {FontType, PDFDancer} from '../../index';
|
|
7
7
|
import {createTempPath, requireEnvAndFixture} from './test-helpers';
|
|
8
8
|
import {expectWithin} from '../assertions';
|
|
9
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
9
10
|
|
|
10
11
|
describe('Text Line E2E Tests (v2 API)', () => {
|
|
11
12
|
|
|
@@ -17,16 +18,22 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
17
18
|
expect(lines).toHaveLength(340);
|
|
18
19
|
|
|
19
20
|
const first = lines[0];
|
|
20
|
-
expect(first.internalId).toBe('
|
|
21
|
+
expect(first.internalId).toBe('TEXTLINE_000001');
|
|
21
22
|
expect(first.position).toBeDefined();
|
|
22
23
|
expectWithin(first.position.boundingRect?.x, 326, 1);
|
|
23
24
|
expectWithin(first.position.boundingRect?.y, 706, 1);
|
|
25
|
+
expect(first.objectRef().status).toBeDefined();
|
|
26
|
+
expect(first.objectRef().status?.isModified()).toBe(false);
|
|
27
|
+
expect(first.objectRef().status?.isEncodable()).toBe(true);
|
|
24
28
|
|
|
25
29
|
const last = lines[lines.length - 1];
|
|
26
|
-
expect(last.internalId).toBe('
|
|
30
|
+
expect(last.internalId).toBe('TEXTLINE_000340');
|
|
27
31
|
expect(last.position).toBeDefined();
|
|
28
32
|
expectWithin(last.position.boundingRect?.x, 548, 1);
|
|
29
33
|
expectWithin(last.position.boundingRect?.y, 35, 1);
|
|
34
|
+
expect(last.objectRef().status).toBeDefined();
|
|
35
|
+
expect(last.objectRef().status?.isModified()).toBe(false);
|
|
36
|
+
expect(last.objectRef().status?.isEncodable()).toBe(true);
|
|
30
37
|
});
|
|
31
38
|
|
|
32
39
|
test('find lines on page', async () => {
|
|
@@ -37,7 +44,7 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
37
44
|
expect(lines).toHaveLength(26);
|
|
38
45
|
|
|
39
46
|
const line = lines[0];
|
|
40
|
-
expect(line.internalId).toBe('
|
|
47
|
+
expect(line.internalId).toBe('TEXTLINE_000005');
|
|
41
48
|
expect(line.position).toBeDefined();
|
|
42
49
|
});
|
|
43
50
|
|
|
@@ -49,7 +56,7 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
49
56
|
expect(lines).toHaveLength(1);
|
|
50
57
|
|
|
51
58
|
const line = lines[0];
|
|
52
|
-
expect(line.internalId).toBe('
|
|
59
|
+
expect(line.internalId).toBe('TEXTLINE_000002');
|
|
53
60
|
expect(line.position).toBeDefined();
|
|
54
61
|
expectWithin(line.position.boundingRect?.x, 54, 1);
|
|
55
62
|
expectWithin(line.position.boundingRect?.y, 606, 2);
|
|
@@ -73,6 +80,9 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
73
80
|
expect(fs.statSync(outPath).size).toBeGreaterThan(0);
|
|
74
81
|
|
|
75
82
|
fs.unlinkSync(outPath);
|
|
83
|
+
|
|
84
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
85
|
+
await assertions.assertTextlineDoesNotExist('The Complete');
|
|
76
86
|
});
|
|
77
87
|
|
|
78
88
|
test('move line', async () => {
|
|
@@ -93,6 +103,9 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
93
103
|
expect(fs.statSync(outPath).size).toBeGreaterThan(0);
|
|
94
104
|
|
|
95
105
|
fs.unlinkSync(outPath);
|
|
106
|
+
|
|
107
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
108
|
+
await assertions.assertTextlineIsAt('The Complete', newX, newY, 0, 0.25);
|
|
96
109
|
});
|
|
97
110
|
|
|
98
111
|
test('modify line', async () => {
|
|
@@ -100,7 +113,11 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
100
113
|
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
101
114
|
|
|
102
115
|
const [line] = await pdf.page(0).selectTextLinesStartingWith('The Complete');
|
|
103
|
-
await line.edit().text(' replaced ').apply();
|
|
116
|
+
const result = await line.edit().text(' replaced ').apply();
|
|
117
|
+
|
|
118
|
+
// This should issue a warning about an embedded font modification
|
|
119
|
+
expect(result.warning).toBeDefined();
|
|
120
|
+
expect(result.warning).toContain('You are using an embedded font and modified the text.');
|
|
104
121
|
|
|
105
122
|
const outPath = createTempPath('modifyLine.pdf');
|
|
106
123
|
await pdf.save(outPath);
|
|
@@ -110,6 +127,13 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
110
127
|
const stillOld = await pdf.page(0).selectParagraphsStartingWith('The Complete');
|
|
111
128
|
expect(stillOld).toHaveLength(0);
|
|
112
129
|
|
|
130
|
+
const lines = await pdf.page(0).selectTextLinesStartingWith(' replaced ');
|
|
131
|
+
expect(lines.length).toBeGreaterThan(0);
|
|
132
|
+
expect(lines[0].objectRef().status).toBeDefined();
|
|
133
|
+
expect(lines[0].objectRef().status?.isEncodable()).toBe(true);
|
|
134
|
+
expect(lines[0].objectRef().status?.getFontType()).toBe(FontType.EMBEDDED);
|
|
135
|
+
expect(lines[0].objectRef().status?.isModified()).toBe(true);
|
|
136
|
+
|
|
113
137
|
const replaced = await pdf.page(0).selectParagraphsStartingWith(' replaced ');
|
|
114
138
|
expect(replaced.length).toBeGreaterThan(0);
|
|
115
139
|
|
|
@@ -117,5 +141,8 @@ describe('Text Line E2E Tests (v2 API)', () => {
|
|
|
117
141
|
expect(containingParas.length).toBeGreaterThan(0);
|
|
118
142
|
|
|
119
143
|
fs.unlinkSync(outPath);
|
|
144
|
+
|
|
145
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
146
|
+
await assertions.assertTextlineExists(' replaced ');
|
|
120
147
|
});
|
|
121
148
|
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {ObjectType, PDFDancer} from '../../index';
|
|
6
6
|
import {requireEnvAndFixture} from './test-helpers';
|
|
7
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
7
8
|
|
|
8
9
|
describe('Page E2E Tests', () => {
|
|
9
10
|
// Tests should fail properly if environment is not configured
|
|
@@ -39,5 +40,8 @@ describe('Page E2E Tests', () => {
|
|
|
39
40
|
|
|
40
41
|
const newPages = await client.pages();
|
|
41
42
|
expect(newPages).toHaveLength(11);
|
|
43
|
+
|
|
44
|
+
const assertions = await PDFAssertions.create(client);
|
|
45
|
+
await assertions.assertPageCount(11);
|
|
42
46
|
});
|
|
43
47
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* E2E tests for paragraph operations — new PDFDancer API
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {Color, PDFDancer, StandardFonts} from '../../index';
|
|
5
|
+
import {Color, FontType, PDFDancer, StandardFonts} from '../../index';
|
|
6
6
|
import {getFontPath, readFontFixture, requireEnvAndFixture} from './test-helpers';
|
|
7
7
|
import {expectWithin} from '../assertions';
|
|
8
8
|
import {PDFAssertions} from './pdf-assertions';
|
|
@@ -30,6 +30,11 @@ describe('Paragraph E2E Tests (v2 API)', () => {
|
|
|
30
30
|
expect(last.position).toBeDefined();
|
|
31
31
|
expectWithin(last.position.boundingRect?.x, 54, 1);
|
|
32
32
|
expectWithin(last.position.boundingRect?.y, 496, 2);
|
|
33
|
+
|
|
34
|
+
expect(last.objectRef().status).toBeDefined();
|
|
35
|
+
expect(last.objectRef().status?.isEncodable()).toBe(true);
|
|
36
|
+
expect(last.objectRef().status?.getFontType()).toBe(FontType.EMBEDDED);
|
|
37
|
+
expect(last.objectRef().status?.isModified()).toBe(false);
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
test('find paragraphs by text', async () => {
|
|
@@ -103,6 +108,14 @@ describe('Paragraph E2E Tests (v2 API)', () => {
|
|
|
103
108
|
|
|
104
109
|
await assertNewParagraphExists(pdf);
|
|
105
110
|
|
|
111
|
+
const movedParas = await pdf.page(0).selectParagraphsAt(300.1, 500);
|
|
112
|
+
expect(movedParas.length).toBeGreaterThan(0);
|
|
113
|
+
const moved = movedParas[0];
|
|
114
|
+
expect(moved.objectRef().status).toBeDefined();
|
|
115
|
+
expect(moved.objectRef().status?.isEncodable()).toBe(true);
|
|
116
|
+
expect(moved.objectRef().status?.getFontType()).toBe(FontType.STANDARD);
|
|
117
|
+
expect(moved.objectRef().status?.isModified()).toBe(true);
|
|
118
|
+
|
|
106
119
|
const assertions = await PDFAssertions.create(pdf);
|
|
107
120
|
await assertions.assertTextlineHasFont('Awesomely', 'Helvetica', 12, 0);
|
|
108
121
|
await assertions.assertTextlineHasFont('Obvious!', 'Helvetica', 12, 0);
|
|
@@ -116,9 +129,23 @@ describe('Paragraph E2E Tests (v2 API)', () => {
|
|
|
116
129
|
const pdf = await PDFDancer.open(pdfData, token, baseUrl);
|
|
117
130
|
|
|
118
131
|
const [para] = await pdf.page(0).selectParagraphsStartingWith('The Complete');
|
|
119
|
-
await para.edit().replace('Awesomely\nObvious!').apply();
|
|
132
|
+
const result = await para.edit().replace('Awesomely\nObvious!').apply();
|
|
133
|
+
|
|
134
|
+
// This should issue a warning about an embedded font modification
|
|
135
|
+
expect(typeof result).toBe('object');
|
|
136
|
+
expect((result as any).warning).toBeDefined();
|
|
137
|
+
expect((result as any).warning).toContain('You are using an embedded font and modified the text.');
|
|
138
|
+
|
|
120
139
|
await assertNewParagraphExists(pdf);
|
|
121
140
|
|
|
141
|
+
const modifiedParas = await pdf.page(0).selectParagraphsStartingWith('Awesomely');
|
|
142
|
+
expect(modifiedParas.length).toBeGreaterThan(0);
|
|
143
|
+
const modified = modifiedParas[0];
|
|
144
|
+
expect(modified.objectRef().status).toBeDefined();
|
|
145
|
+
expect(modified.objectRef().status?.isEncodable()).toBe(true);
|
|
146
|
+
expect(modified.objectRef().status?.getFontType()).toBe(FontType.EMBEDDED);
|
|
147
|
+
expect(modified.objectRef().status?.isModified()).toBe(true);
|
|
148
|
+
|
|
122
149
|
const assertions = await PDFAssertions.create(pdf);
|
|
123
150
|
await assertions.assertTextlineHasFont('Awesomely', 'IXKSWR+Poppins-Bold', 1, 0);
|
|
124
151
|
await assertions.assertTextlineHasFont('Obvious!', 'IXKSWR+Poppins-Bold', 1, 0);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {requireEnvAndFixture} from './test-helpers';
|
|
6
6
|
import {PDFDancer} from "../../pdfdancer_v1";
|
|
7
|
+
import {PDFAssertions} from './pdf-assertions';
|
|
7
8
|
|
|
8
9
|
describe('Path E2E Tests (New API)', () => {
|
|
9
10
|
|
|
@@ -47,6 +48,10 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
47
48
|
|
|
48
49
|
const allPaths = await pdf.selectPaths();
|
|
49
50
|
expect(allPaths).toHaveLength(8);
|
|
51
|
+
|
|
52
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
53
|
+
await assertions.assertNoPathAt(80, 720);
|
|
54
|
+
await assertions.assertNumberOfPaths(8);
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
test('move path', async () => {
|
|
@@ -67,5 +72,8 @@ describe('Path E2E Tests (New API)', () => {
|
|
|
67
72
|
const movedPos = moved[0].position;
|
|
68
73
|
expect(movedPos.getX()).toBeCloseTo(50.1, 1);
|
|
69
74
|
expect(movedPos.getY()).toBeCloseTo(100, 1);
|
|
75
|
+
|
|
76
|
+
const assertions = await PDFAssertions.create(pdf);
|
|
77
|
+
await assertions.assertPathIsAt('PATH_000001', 50.1, 100);
|
|
70
78
|
});
|
|
71
79
|
});
|