pdf-lite 1.4.0 → 1.5.0
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/dist/acroform/acroform.d.ts +3 -3
- package/dist/acroform/acroform.js +2 -2
- package/dist/acroform/appearance/index.d.ts +4 -4
- package/dist/acroform/appearance/index.js +4 -4
- package/dist/acroform/appearance/{PdfAppearanceStream.d.ts → pdf-appearance-stream.d.ts} +9 -3
- package/dist/acroform/appearance/{PdfAppearanceStream.js → pdf-appearance-stream.js} +14 -5
- package/dist/acroform/appearance/{PdfButtonAppearanceStream.d.ts → pdf-button-appearance-stream.d.ts} +3 -2
- package/dist/acroform/appearance/pdf-button-appearance-stream.js +54 -0
- package/dist/acroform/appearance/pdf-choice-appearance-stream.d.ts +22 -0
- package/dist/acroform/appearance/pdf-choice-appearance-stream.js +75 -0
- package/dist/acroform/appearance/pdf-graphics.d.ts +51 -0
- package/dist/acroform/appearance/pdf-graphics.js +239 -0
- package/dist/acroform/appearance/{PdfTextAppearanceStream.d.ts → pdf-text-appearance-stream.d.ts} +7 -2
- package/dist/acroform/appearance/pdf-text-appearance-stream.js +104 -0
- package/dist/acroform/fields/index.d.ts +7 -7
- package/dist/acroform/fields/index.js +7 -7
- package/dist/acroform/fields/pdf-button-form-field.d.ts +23 -0
- package/dist/acroform/fields/pdf-button-form-field.js +102 -0
- package/dist/acroform/fields/pdf-choice-form-field.d.ts +18 -0
- package/dist/acroform/fields/pdf-choice-form-field.js +131 -0
- package/dist/acroform/fields/{PdfFormFieldFlags.d.ts → pdf-form-field-flags.d.ts} +5 -6
- package/dist/acroform/fields/{PdfFormFieldFlags.js → pdf-form-field-flags.js} +12 -18
- package/dist/acroform/fields/{PdfFormField.d.ts → pdf-form-field.d.ts} +15 -11
- package/dist/acroform/fields/{PdfFormField.js → pdf-form-field.js} +68 -134
- package/dist/acroform/fields/{PdfSignatureFormField.d.ts → pdf-signature-form-field.d.ts} +1 -1
- package/dist/acroform/fields/{PdfSignatureFormField.js → pdf-signature-form-field.js} +1 -1
- package/dist/acroform/fields/{PdfTextFormField.d.ts → pdf-text-form-field.d.ts} +1 -1
- package/dist/acroform/fields/pdf-text-form-field.js +77 -0
- package/dist/acroform/fields/types.d.ts +5 -0
- package/dist/acroform/index.d.ts +2 -2
- package/dist/acroform/index.js +2 -2
- package/dist/acroform/manager.d.ts +7 -3
- package/dist/acroform/manager.js +14 -8
- package/dist/acroform/{PdfAcroForm.d.ts → pdf-acro-form.d.ts} +12 -6
- package/dist/acroform/{PdfAcroForm.js → pdf-acro-form.js} +43 -29
- package/dist/acroform/{PdfFontEncodingCache.d.ts → pdf-font-encoding-cache.d.ts} +11 -0
- package/dist/acroform/pdf-font-encoding-cache.js +188 -0
- package/dist/acroform/xfa/index.d.ts +3 -3
- package/dist/acroform/xfa/index.js +2 -2
- package/dist/acroform/xfa/{PdfXfaForm.d.ts → pdf-xfa-form.d.ts} +1 -2
- package/dist/acroform/xfa/{PdfXfaForm.js → pdf-xfa-form.js} +2 -10
- package/dist/annotations/index.d.ts +4 -4
- package/dist/annotations/index.js +4 -4
- package/dist/annotations/{PdfAnnotationFlags.d.ts → pdf-annotation-flags.d.ts} +3 -4
- package/dist/annotations/{PdfAnnotationFlags.js → pdf-annotation-flags.js} +5 -6
- package/dist/annotations/{PdfAnnotation.d.ts → pdf-annotation.d.ts} +25 -4
- package/dist/annotations/{PdfAnnotation.js → pdf-annotation.js} +4 -3
- package/dist/annotations/{PdfWidgetAnnotation.d.ts → pdf-widget-annotation.d.ts} +1 -1
- package/dist/annotations/{PdfWidgetAnnotation.js → pdf-widget-annotation.js} +1 -1
- package/dist/core/objects/pdf-stream.d.ts +1 -0
- package/dist/core/objects/pdf-stream.js +6 -2
- package/dist/core/parser/incremental-parser.d.ts +0 -13
- package/dist/core/parser/incremental-parser.js +1 -18
- package/dist/core/streams/object-stream.d.ts +1 -1
- package/dist/core/streams/object-stream.js +1 -1
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +24 -0
- package/dist/fonts/index.d.ts +1 -1
- package/dist/fonts/index.js +1 -1
- package/dist/fonts/pdf-font.d.ts +64 -7
- package/dist/fonts/pdf-font.js +188 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pdf/index.d.ts +0 -1
- package/dist/pdf/index.js +0 -1
- package/dist/pdf/pdf-document.d.ts +2 -1
- package/dist/pdf/pdf-document.js +15 -11
- package/dist/utils/encodePdfText.d.ts +17 -0
- package/dist/utils/encodePdfText.js +61 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/acroform/PdfFontEncodingCache.js +0 -75
- package/dist/acroform/appearance/PdfButtonAppearanceStream.js +0 -54
- package/dist/acroform/appearance/PdfChoiceAppearanceStream.d.ts +0 -15
- package/dist/acroform/appearance/PdfChoiceAppearanceStream.js +0 -48
- package/dist/acroform/appearance/PdfTextAppearanceStream.js +0 -75
- package/dist/acroform/fields/PdfButtonFormField.d.ts +0 -9
- package/dist/acroform/fields/PdfButtonFormField.js +0 -35
- package/dist/acroform/fields/PdfChoiceFormField.d.ts +0 -9
- package/dist/acroform/fields/PdfChoiceFormField.js +0 -46
- package/dist/acroform/fields/PdfTextFormField.js +0 -52
- package/dist/pdf/errors.d.ts +0 -6
- package/dist/pdf/errors.js +0 -6
- /package/dist/acroform/fields/{PdfDefaultAppearance.d.ts → pdf-default-appearance.d.ts} +0 -0
- /package/dist/acroform/fields/{PdfDefaultAppearance.js → pdf-default-appearance.js} +0 -0
- /package/dist/acroform/xfa/{PdfXfaData.d.ts → pdf-xfa-data.d.ts} +0 -0
- /package/dist/acroform/xfa/{PdfXfaData.js → pdf-xfa-data.js} +0 -0
- /package/dist/annotations/{PdfAnnotationWriter.d.ts → pdf-annotation-writer.d.ts} +0 -0
- /package/dist/annotations/{PdfAnnotationWriter.js → pdf-annotation-writer.js} +0 -0
- /package/dist/fonts/{font-manager.d.ts → manager.d.ts} +0 -0
- /package/dist/fonts/{font-manager.js → manager.js} +0 -0
- /package/dist/utils/{IterableReadableStream.d.ts → iterable-readable-stream.d.ts} +0 -0
- /package/dist/utils/{IterableReadableStream.js → iterable-readable-stream.js} +0 -0
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { PdfDictionary } from '../core/objects/pdf-dictionary.js';
|
|
2
|
-
import { PdfArray } from '../core/objects/pdf-array.js';
|
|
3
|
-
import { PdfString } from '../core/objects/pdf-string.js';
|
|
4
|
-
import { PdfObjectReference } from '../core/objects/pdf-object-reference.js';
|
|
5
|
-
import { buildEncodingMap } from '../utils/decodeWithFontEncoding.js';
|
|
6
|
-
/**
|
|
7
|
-
* Resolves and caches font encoding maps from the form's default resources.
|
|
8
|
-
*/
|
|
9
|
-
export class PdfFontEncodingCache {
|
|
10
|
-
fontEncodingMaps = new Map();
|
|
11
|
-
document;
|
|
12
|
-
defaultResources;
|
|
13
|
-
constructor(document, defaultResources) {
|
|
14
|
-
this.document = document;
|
|
15
|
-
this.defaultResources = defaultResources;
|
|
16
|
-
}
|
|
17
|
-
async getFontEncodingMap(fontName) {
|
|
18
|
-
if (this.fontEncodingMaps.has(fontName)) {
|
|
19
|
-
return this.fontEncodingMaps.get(fontName);
|
|
20
|
-
}
|
|
21
|
-
const dr = this.defaultResources;
|
|
22
|
-
if (!dr)
|
|
23
|
-
return null;
|
|
24
|
-
const fonts = dr.get('Font')?.as(PdfDictionary);
|
|
25
|
-
if (!fonts)
|
|
26
|
-
return null;
|
|
27
|
-
const fontRef = fonts.get(fontName)?.as(PdfObjectReference);
|
|
28
|
-
if (!fontRef || !this.document)
|
|
29
|
-
return null;
|
|
30
|
-
const fontObj = await this.document.readObject({
|
|
31
|
-
objectNumber: fontRef.objectNumber,
|
|
32
|
-
generationNumber: fontRef.generationNumber,
|
|
33
|
-
});
|
|
34
|
-
if (!fontObj)
|
|
35
|
-
return null;
|
|
36
|
-
const fontDict = fontObj.content.as(PdfDictionary);
|
|
37
|
-
const encoding = fontDict.get('Encoding');
|
|
38
|
-
let encodingDict = null;
|
|
39
|
-
if (encoding instanceof PdfObjectReference) {
|
|
40
|
-
const encodingObj = await this.document.readObject({
|
|
41
|
-
objectNumber: encoding.objectNumber,
|
|
42
|
-
generationNumber: encoding.generationNumber,
|
|
43
|
-
});
|
|
44
|
-
encodingDict = encodingObj?.content.as(PdfDictionary) ?? null;
|
|
45
|
-
}
|
|
46
|
-
else if (encoding instanceof PdfDictionary) {
|
|
47
|
-
encodingDict = encoding;
|
|
48
|
-
}
|
|
49
|
-
if (!encodingDict)
|
|
50
|
-
return null;
|
|
51
|
-
const differences = encodingDict.get('Differences')?.as(PdfArray);
|
|
52
|
-
if (!differences)
|
|
53
|
-
return null;
|
|
54
|
-
const encodingMap = buildEncodingMap(differences);
|
|
55
|
-
if (!encodingMap)
|
|
56
|
-
return null;
|
|
57
|
-
this.fontEncodingMaps.set(fontName, encodingMap);
|
|
58
|
-
return encodingMap;
|
|
59
|
-
}
|
|
60
|
-
async cacheAllFontEncodings(fields) {
|
|
61
|
-
const fontNames = new Set();
|
|
62
|
-
for (const field of fields) {
|
|
63
|
-
const da = field.content.get('DA')?.as(PdfString)?.value;
|
|
64
|
-
if (da) {
|
|
65
|
-
const fontMatch = da.match(/\/(\w+)\s+[\d.]+\s+Tf/);
|
|
66
|
-
if (fontMatch) {
|
|
67
|
-
fontNames.add(fontMatch[1]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
for (const fontName of fontNames) {
|
|
72
|
-
await this.getFontEncodingMap(fontName);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { PdfDictionary } from '../../core/objects/pdf-dictionary.js';
|
|
2
|
-
import { PdfName } from '../../core/objects/pdf-name.js';
|
|
3
|
-
import { PdfAppearanceStream } from './PdfAppearanceStream.js';
|
|
4
|
-
/**
|
|
5
|
-
* Appearance stream for button fields (checkboxes, radio buttons).
|
|
6
|
-
*/
|
|
7
|
-
export class PdfButtonAppearanceStream extends PdfAppearanceStream {
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
const resources = new PdfDictionary();
|
|
10
|
-
const fonts = new PdfDictionary();
|
|
11
|
-
const zapfFont = new PdfDictionary();
|
|
12
|
-
zapfFont.set('Type', new PdfName('Font'));
|
|
13
|
-
zapfFont.set('Subtype', new PdfName('Type1'));
|
|
14
|
-
zapfFont.set('BaseFont', new PdfName('ZapfDingbats'));
|
|
15
|
-
fonts.set('ZaDb', zapfFont);
|
|
16
|
-
resources.set('Font', fonts);
|
|
17
|
-
super({
|
|
18
|
-
width: ctx.width,
|
|
19
|
-
height: ctx.height,
|
|
20
|
-
contentStream: ctx.contentStream,
|
|
21
|
-
resources,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
static buildYesContent(width, height, flags) {
|
|
25
|
-
const size = Math.min(width, height);
|
|
26
|
-
const isRadio = (flags & 32768) !== 0;
|
|
27
|
-
if (isRadio) {
|
|
28
|
-
const center = size / 2;
|
|
29
|
-
const radius = size * 0.35;
|
|
30
|
-
const k = 0.5522847498;
|
|
31
|
-
const kRadius = k * radius;
|
|
32
|
-
return `q
|
|
33
|
-
0 0 0 rg
|
|
34
|
-
${center} ${center + radius} m
|
|
35
|
-
${center + kRadius} ${center + radius} ${center + radius} ${center + kRadius} ${center + radius} ${center} c
|
|
36
|
-
${center + radius} ${center - kRadius} ${center + kRadius} ${center - radius} ${center} ${center - radius} c
|
|
37
|
-
${center - kRadius} ${center - radius} ${center - radius} ${center - kRadius} ${center - radius} ${center} c
|
|
38
|
-
${center - radius} ${center + kRadius} ${center - kRadius} ${center + radius} ${center} ${center + radius} c
|
|
39
|
-
f
|
|
40
|
-
Q
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
const checkSize = size * 0.8;
|
|
44
|
-
const offset = (size - checkSize) / 2;
|
|
45
|
-
return `q
|
|
46
|
-
BT
|
|
47
|
-
/ZaDb ${checkSize} Tf
|
|
48
|
-
${offset} ${offset} Td
|
|
49
|
-
(4) Tj
|
|
50
|
-
ET
|
|
51
|
-
Q
|
|
52
|
-
`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PdfDefaultAppearance } from '../fields/PdfDefaultAppearance.js';
|
|
2
|
-
import { PdfAppearanceStream } from './PdfAppearanceStream.js';
|
|
3
|
-
import type { PdfDictionary } from '../../core/objects/pdf-dictionary.js';
|
|
4
|
-
/**
|
|
5
|
-
* Appearance stream for choice fields (dropdowns, list boxes).
|
|
6
|
-
*/
|
|
7
|
-
export declare class PdfChoiceAppearanceStream extends PdfAppearanceStream {
|
|
8
|
-
constructor(ctx: {
|
|
9
|
-
rect: [number, number, number, number];
|
|
10
|
-
value: string;
|
|
11
|
-
da: PdfDefaultAppearance;
|
|
12
|
-
flags: number;
|
|
13
|
-
fontResources?: PdfDictionary;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PdfAppearanceStream } from './PdfAppearanceStream.js';
|
|
2
|
-
/**
|
|
3
|
-
* Appearance stream for choice fields (dropdowns, list boxes).
|
|
4
|
-
*/
|
|
5
|
-
export class PdfChoiceAppearanceStream extends PdfAppearanceStream {
|
|
6
|
-
constructor(ctx) {
|
|
7
|
-
const [x1, y1, x2, y2] = ctx.rect;
|
|
8
|
-
const width = x2 - x1;
|
|
9
|
-
const height = y2 - y1;
|
|
10
|
-
const colorOp = '0 g';
|
|
11
|
-
const reconstructedDA = `/${ctx.da.fontName} ${ctx.da.fontSize} Tf ${colorOp}`;
|
|
12
|
-
const padding = 2;
|
|
13
|
-
const textY = (height - ctx.da.fontSize) / 2 + ctx.da.fontSize * 0.2;
|
|
14
|
-
const textX = padding;
|
|
15
|
-
const escapedValue = ctx.value
|
|
16
|
-
.replace(/\\/g, '\\\\')
|
|
17
|
-
.replace(/\(/g, '\\(')
|
|
18
|
-
.replace(/\)/g, '\\)');
|
|
19
|
-
const isCombo = (ctx.flags & 131072) !== 0;
|
|
20
|
-
let arrowGraphics = '';
|
|
21
|
-
if (isCombo) {
|
|
22
|
-
const arrowWidth = height * 0.8;
|
|
23
|
-
const arrowX = width - arrowWidth - 2;
|
|
24
|
-
const arrowY = height / 2;
|
|
25
|
-
const arrowSize = height * 0.3;
|
|
26
|
-
arrowGraphics = `
|
|
27
|
-
q
|
|
28
|
-
0.5 0.5 0.5 rg
|
|
29
|
-
${arrowX + arrowWidth / 2} ${arrowY - arrowSize / 3} m
|
|
30
|
-
${arrowX + arrowWidth / 2 - arrowSize / 2} ${arrowY + arrowSize / 3} l
|
|
31
|
-
${arrowX + arrowWidth / 2 + arrowSize / 2} ${arrowY + arrowSize / 3} l
|
|
32
|
-
f
|
|
33
|
-
Q
|
|
34
|
-
`;
|
|
35
|
-
}
|
|
36
|
-
const contentStream = `/Tx BMC
|
|
37
|
-
q
|
|
38
|
-
BT
|
|
39
|
-
${reconstructedDA}
|
|
40
|
-
${textX} ${textY} Td
|
|
41
|
-
(${escapedValue}) Tj
|
|
42
|
-
ET
|
|
43
|
-
${arrowGraphics}Q
|
|
44
|
-
EMC
|
|
45
|
-
`;
|
|
46
|
-
super({ width, height, contentStream, resources: ctx.fontResources });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { PdfAppearanceStream } from './PdfAppearanceStream.js';
|
|
2
|
-
/**
|
|
3
|
-
* Appearance stream for text fields (single-line, multiline, comb).
|
|
4
|
-
*/
|
|
5
|
-
export class PdfTextAppearanceStream extends PdfAppearanceStream {
|
|
6
|
-
constructor(ctx) {
|
|
7
|
-
const [x1, y1, x2, y2] = ctx.rect;
|
|
8
|
-
const width = x2 - x1;
|
|
9
|
-
const height = y2 - y1;
|
|
10
|
-
const value = ctx.value;
|
|
11
|
-
const reconstructedDA = ctx.da.toString();
|
|
12
|
-
const fontSize = ctx.da.fontSize;
|
|
13
|
-
const padding = 2;
|
|
14
|
-
const textY = (height - fontSize) / 2 + fontSize * 0.2;
|
|
15
|
-
const escapedValue = value
|
|
16
|
-
.replace(/\\/g, '\\\\')
|
|
17
|
-
.replace(/\(/g, '\\(')
|
|
18
|
-
.replace(/\)/g, '\\)')
|
|
19
|
-
.replace(/\r/g, '\\r')
|
|
20
|
-
.replace(/\n/g, '\\n');
|
|
21
|
-
let textContent;
|
|
22
|
-
if (ctx.multiline) {
|
|
23
|
-
const lines = value.split('\n');
|
|
24
|
-
const lineHeight = fontSize * 1.2;
|
|
25
|
-
const startY = height - padding - fontSize;
|
|
26
|
-
textContent = 'BT\n';
|
|
27
|
-
textContent += `${reconstructedDA}\n`;
|
|
28
|
-
textContent += `${padding} ${startY} Td\n`;
|
|
29
|
-
for (let i = 0; i < lines.length; i++) {
|
|
30
|
-
const line = lines[i]
|
|
31
|
-
.replace(/\\/g, '\\\\')
|
|
32
|
-
.replace(/\(/g, '\\(')
|
|
33
|
-
.replace(/\)/g, '\\)')
|
|
34
|
-
.replace(/\r/g, '');
|
|
35
|
-
if (i > 0) {
|
|
36
|
-
textContent += `0 ${-lineHeight} Td\n`;
|
|
37
|
-
}
|
|
38
|
-
textContent += `(${line}) Tj\n`;
|
|
39
|
-
}
|
|
40
|
-
textContent += 'ET\n';
|
|
41
|
-
}
|
|
42
|
-
else if (ctx.comb && ctx.maxLen) {
|
|
43
|
-
const cellWidth = width / ctx.maxLen;
|
|
44
|
-
const chars = value.split('');
|
|
45
|
-
textContent = 'BT\n';
|
|
46
|
-
textContent += `${reconstructedDA}\n`;
|
|
47
|
-
for (let i = 0; i < chars.length && i < ctx.maxLen; i++) {
|
|
48
|
-
const cellX = cellWidth * i + cellWidth / 2 - fontSize * 0.3;
|
|
49
|
-
const escapedChar = chars[i]
|
|
50
|
-
.replace(/\\/g, '\\\\')
|
|
51
|
-
.replace(/\(/g, '\\(')
|
|
52
|
-
.replace(/\)/g, '\\)');
|
|
53
|
-
textContent += `${cellX} ${textY} Td\n`;
|
|
54
|
-
textContent += `(${escapedChar}) Tj\n`;
|
|
55
|
-
textContent += `${-cellX} ${-textY} Td\n`;
|
|
56
|
-
}
|
|
57
|
-
textContent += 'ET\n';
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const textX = padding;
|
|
61
|
-
textContent = `BT
|
|
62
|
-
${reconstructedDA}
|
|
63
|
-
${textX} ${textY} Td
|
|
64
|
-
(${escapedValue}) Tj
|
|
65
|
-
ET
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
const contentStream = `/Tx BMC
|
|
69
|
-
q
|
|
70
|
-
${textContent}Q
|
|
71
|
-
EMC
|
|
72
|
-
`;
|
|
73
|
-
super({ width, height, contentStream, resources: ctx.fontResources });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PdfFormField } from './PdfFormField.js';
|
|
2
|
-
/**
|
|
3
|
-
* Button form field subtype (checkboxes, radio buttons, push buttons).
|
|
4
|
-
*/
|
|
5
|
-
export declare class PdfButtonFormField extends PdfFormField {
|
|
6
|
-
generateAppearance(options?: {
|
|
7
|
-
makeReadOnly?: boolean;
|
|
8
|
-
}): boolean;
|
|
9
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PdfFormField } from './PdfFormField.js';
|
|
2
|
-
import { PdfButtonAppearanceStream } from '../appearance/PdfButtonAppearanceStream.js';
|
|
3
|
-
/**
|
|
4
|
-
* Button form field subtype (checkboxes, radio buttons, push buttons).
|
|
5
|
-
*/
|
|
6
|
-
export class PdfButtonFormField extends PdfFormField {
|
|
7
|
-
static {
|
|
8
|
-
PdfFormField.registerFieldType('Btn', PdfButtonFormField);
|
|
9
|
-
}
|
|
10
|
-
generateAppearance(options) {
|
|
11
|
-
const rect = this.rect;
|
|
12
|
-
if (!rect || rect.length !== 4)
|
|
13
|
-
return false;
|
|
14
|
-
const [x1, y1, x2, y2] = rect;
|
|
15
|
-
const width = x2 - x1;
|
|
16
|
-
const height = y2 - y1;
|
|
17
|
-
this._appearanceStream = new PdfButtonAppearanceStream({
|
|
18
|
-
width,
|
|
19
|
-
height,
|
|
20
|
-
contentStream: '',
|
|
21
|
-
});
|
|
22
|
-
const yesContent = PdfButtonAppearanceStream.buildYesContent(width, height, this.flags);
|
|
23
|
-
this._appearanceStreamYes = new PdfButtonAppearanceStream({
|
|
24
|
-
width,
|
|
25
|
-
height,
|
|
26
|
-
contentStream: yesContent,
|
|
27
|
-
});
|
|
28
|
-
if (options?.makeReadOnly) {
|
|
29
|
-
this.readOnly = true;
|
|
30
|
-
this.print = true;
|
|
31
|
-
this.noZoom = true;
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { PdfFormField } from './PdfFormField.js';
|
|
2
|
-
import { PdfDefaultAppearance } from './PdfDefaultAppearance.js';
|
|
3
|
-
import { PdfChoiceAppearanceStream } from '../appearance/PdfChoiceAppearanceStream.js';
|
|
4
|
-
import { PdfDictionary } from '../../core/objects/pdf-dictionary.js';
|
|
5
|
-
/**
|
|
6
|
-
* Choice form field subtype (dropdowns, list boxes).
|
|
7
|
-
*/
|
|
8
|
-
export class PdfChoiceFormField extends PdfFormField {
|
|
9
|
-
static {
|
|
10
|
-
PdfFormField.registerFieldType('Ch', PdfChoiceFormField);
|
|
11
|
-
}
|
|
12
|
-
generateAppearance(options) {
|
|
13
|
-
const rect = this.rect;
|
|
14
|
-
if (!rect || rect.length !== 4)
|
|
15
|
-
return false;
|
|
16
|
-
const da = this.defaultAppearance;
|
|
17
|
-
if (!da)
|
|
18
|
-
return false;
|
|
19
|
-
const value = this.value;
|
|
20
|
-
if (!value)
|
|
21
|
-
return false;
|
|
22
|
-
const parsed = PdfDefaultAppearance.parse(da);
|
|
23
|
-
if (!parsed)
|
|
24
|
-
return false;
|
|
25
|
-
let fontResources;
|
|
26
|
-
const drFontValue = this.form?.defaultResources?.get('Font');
|
|
27
|
-
const drFonts = drFontValue instanceof PdfDictionary ? drFontValue : undefined;
|
|
28
|
-
if (drFonts) {
|
|
29
|
-
fontResources = new PdfDictionary();
|
|
30
|
-
fontResources.set('Font', drFonts);
|
|
31
|
-
}
|
|
32
|
-
this._appearanceStream = new PdfChoiceAppearanceStream({
|
|
33
|
-
rect: rect,
|
|
34
|
-
value,
|
|
35
|
-
da: parsed,
|
|
36
|
-
flags: this.flags,
|
|
37
|
-
fontResources,
|
|
38
|
-
});
|
|
39
|
-
if (options?.makeReadOnly) {
|
|
40
|
-
this.readOnly = true;
|
|
41
|
-
this.print = true;
|
|
42
|
-
this.noZoom = true;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { PdfFormField } from './PdfFormField.js';
|
|
2
|
-
import { PdfDefaultAppearance } from './PdfDefaultAppearance.js';
|
|
3
|
-
import { PdfTextAppearanceStream } from '../appearance/PdfTextAppearanceStream.js';
|
|
4
|
-
import { PdfDictionary } from '../../core/objects/pdf-dictionary.js';
|
|
5
|
-
/**
|
|
6
|
-
* Text form field subtype.
|
|
7
|
-
*/
|
|
8
|
-
export class PdfTextFormField extends PdfFormField {
|
|
9
|
-
static {
|
|
10
|
-
PdfFormField.registerFieldType('Tx', PdfTextFormField, {
|
|
11
|
-
fallback: true,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
generateAppearance(options) {
|
|
15
|
-
const rect = this.rect;
|
|
16
|
-
if (!rect || rect.length !== 4)
|
|
17
|
-
return false;
|
|
18
|
-
const da = this.defaultAppearance;
|
|
19
|
-
if (!da)
|
|
20
|
-
return false;
|
|
21
|
-
const parsed = PdfDefaultAppearance.parse(da);
|
|
22
|
-
if (!parsed)
|
|
23
|
-
return false;
|
|
24
|
-
let fontResources;
|
|
25
|
-
const drFontValue = this.form?.defaultResources?.get('Font');
|
|
26
|
-
const drFonts = drFontValue instanceof PdfDictionary ? drFontValue : undefined;
|
|
27
|
-
if (drFonts) {
|
|
28
|
-
fontResources = new PdfDictionary();
|
|
29
|
-
fontResources.set('Font', drFonts);
|
|
30
|
-
}
|
|
31
|
-
this._appearanceStream = new PdfTextAppearanceStream({
|
|
32
|
-
rect: rect,
|
|
33
|
-
value: this.value,
|
|
34
|
-
da: parsed,
|
|
35
|
-
multiline: this.multiline,
|
|
36
|
-
comb: this.comb,
|
|
37
|
-
maxLen: this.maxLen,
|
|
38
|
-
fontResources,
|
|
39
|
-
});
|
|
40
|
-
if (options?.makeReadOnly) {
|
|
41
|
-
this.readOnly = true;
|
|
42
|
-
if (!this.print)
|
|
43
|
-
this.print = true;
|
|
44
|
-
this.noZoom = true;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
if (!this.print)
|
|
48
|
-
this.print = true;
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
package/dist/pdf/errors.d.ts
DELETED
package/dist/pdf/errors.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|