pdfxml 0.1.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/CHANGELOG.md +17 -0
- package/CONTRIBUTING.md +152 -0
- package/LICENSE +201 -0
- package/README.md +140 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/lib/common/applyBoxStyle.d.ts +3 -0
- package/dist/lib/common/applyBoxStyle.d.ts.map +1 -0
- package/dist/lib/common/applyBoxStyle.js +38 -0
- package/dist/lib/common/applyTextStyle.d.ts +3 -0
- package/dist/lib/common/applyTextStyle.d.ts.map +1 -0
- package/dist/lib/common/applyTextStyle.js +46 -0
- package/dist/lib/common/calculateTableColumnWidths.d.ts +3 -0
- package/dist/lib/common/calculateTableColumnWidths.d.ts.map +1 -0
- package/dist/lib/common/calculateTableColumnWidths.js +57 -0
- package/dist/lib/common/cmToPt.d.ts +2 -0
- package/dist/lib/common/cmToPt.d.ts.map +1 -0
- package/dist/lib/common/cmToPt.js +35 -0
- package/dist/lib/common/extractTableRows.d.ts +3 -0
- package/dist/lib/common/extractTableRows.d.ts.map +1 -0
- package/dist/lib/common/extractTableRows.js +43 -0
- package/dist/lib/common/getFontName.d.ts +2 -0
- package/dist/lib/common/getFontName.d.ts.map +1 -0
- package/dist/lib/common/getFontName.js +33 -0
- package/dist/lib/common/getMargin.d.ts +8 -0
- package/dist/lib/common/getMargin.d.ts.map +1 -0
- package/dist/lib/common/getMargin.js +30 -0
- package/dist/lib/common/getPadding.d.ts +8 -0
- package/dist/lib/common/getPadding.d.ts.map +1 -0
- package/dist/lib/common/getPadding.js +31 -0
- package/dist/lib/common/getSvgSize.d.ts +5 -0
- package/dist/lib/common/getSvgSize.d.ts.map +1 -0
- package/dist/lib/common/getSvgSize.js +40 -0
- package/dist/lib/common/mergeProps.d.ts +3 -0
- package/dist/lib/common/mergeProps.d.ts.map +1 -0
- package/dist/lib/common/mergeProps.js +27 -0
- package/dist/lib/common/normalize.d.ts +3 -0
- package/dist/lib/common/normalize.d.ts.map +1 -0
- package/dist/lib/common/normalize.js +67 -0
- package/dist/lib/common/parseInlineMarkdown.d.ts +3 -0
- package/dist/lib/common/parseInlineMarkdown.d.ts.map +1 -0
- package/dist/lib/common/parseInlineMarkdown.js +65 -0
- package/dist/lib/common/prepareText.d.ts +3 -0
- package/dist/lib/common/prepareText.d.ts.map +1 -0
- package/dist/lib/common/prepareText.js +38 -0
- package/dist/lib/common/resolveSize.d.ts +2 -0
- package/dist/lib/common/resolveSize.d.ts.map +1 -0
- package/dist/lib/common/resolveSize.js +42 -0
- package/dist/lib/common/truncateWithEllipsis.d.ts +2 -0
- package/dist/lib/common/truncateWithEllipsis.d.ts.map +1 -0
- package/dist/lib/common/truncateWithEllipsis.js +42 -0
- package/dist/lib/constants.d.ts +2 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +22 -0
- package/dist/lib/measure/measureFlex.d.ts +3 -0
- package/dist/lib/measure/measureFlex.d.ts.map +1 -0
- package/dist/lib/measure/measureFlex.js +91 -0
- package/dist/lib/measure/measureImage.d.ts +3 -0
- package/dist/lib/measure/measureImage.d.ts.map +1 -0
- package/dist/lib/measure/measureImage.js +37 -0
- package/dist/lib/measure/measureNode.d.ts +3 -0
- package/dist/lib/measure/measureNode.d.ts.map +1 -0
- package/dist/lib/measure/measureNode.js +54 -0
- package/dist/lib/measure/measureTable.d.ts +3 -0
- package/dist/lib/measure/measureTable.d.ts.map +1 -0
- package/dist/lib/measure/measureTable.js +46 -0
- package/dist/lib/measure/measureTableCell.d.ts +3 -0
- package/dist/lib/measure/measureTableCell.d.ts.map +1 -0
- package/dist/lib/measure/measureTableCell.js +57 -0
- package/dist/lib/measure/measureText.d.ts +3 -0
- package/dist/lib/measure/measureText.d.ts.map +1 -0
- package/dist/lib/measure/measureText.js +62 -0
- package/dist/lib/pdf.d.ts +3 -0
- package/dist/lib/pdf.d.ts.map +1 -0
- package/dist/lib/pdf.js +106 -0
- package/dist/lib/render/measureSvg.d.ts +3 -0
- package/dist/lib/render/measureSvg.d.ts.map +1 -0
- package/dist/lib/render/measureSvg.js +30 -0
- package/dist/lib/render/renderBarCode.d.ts +3 -0
- package/dist/lib/render/renderBarCode.d.ts.map +1 -0
- package/dist/lib/render/renderBarCode.js +53 -0
- package/dist/lib/render/renderFlex.d.ts +3 -0
- package/dist/lib/render/renderFlex.d.ts.map +1 -0
- package/dist/lib/render/renderFlex.js +148 -0
- package/dist/lib/render/renderImage.d.ts +3 -0
- package/dist/lib/render/renderImage.d.ts.map +1 -0
- package/dist/lib/render/renderImage.js +41 -0
- package/dist/lib/render/renderNode.d.ts +3 -0
- package/dist/lib/render/renderNode.d.ts.map +1 -0
- package/dist/lib/render/renderNode.js +53 -0
- package/dist/lib/render/renderPage.d.ts +3 -0
- package/dist/lib/render/renderPage.d.ts.map +1 -0
- package/dist/lib/render/renderPage.js +36 -0
- package/dist/lib/render/renderQrCode.d.ts +3 -0
- package/dist/lib/render/renderQrCode.d.ts.map +1 -0
- package/dist/lib/render/renderQrCode.js +45 -0
- package/dist/lib/render/renderSvg.d.ts +3 -0
- package/dist/lib/render/renderSvg.d.ts.map +1 -0
- package/dist/lib/render/renderSvg.js +74 -0
- package/dist/lib/render/renderTable.d.ts +3 -0
- package/dist/lib/render/renderTable.d.ts.map +1 -0
- package/dist/lib/render/renderTable.js +159 -0
- package/dist/lib/render/renderTableCell.d.ts +3 -0
- package/dist/lib/render/renderTableCell.d.ts.map +1 -0
- package/dist/lib/render/renderTableCell.js +70 -0
- package/dist/lib/render/renderText.d.ts +3 -0
- package/dist/lib/render/renderText.d.ts.map +1 -0
- package/dist/lib/render/renderText.js +102 -0
- package/dist/lib/types/BaseProps.d.ts +51 -0
- package/dist/lib/types/BaseProps.d.ts.map +1 -0
- package/dist/lib/types/BaseProps.js +20 -0
- package/dist/lib/types/FlexAlign.d.ts +2 -0
- package/dist/lib/types/FlexAlign.d.ts.map +1 -0
- package/dist/lib/types/FlexAlign.js +20 -0
- package/dist/lib/types/HorizontalTextAlignment.d.ts +2 -0
- package/dist/lib/types/HorizontalTextAlignment.d.ts.map +1 -0
- package/dist/lib/types/HorizontalTextAlignment.js +20 -0
- package/dist/lib/types/LayoutBox.d.ts +7 -0
- package/dist/lib/types/LayoutBox.d.ts.map +1 -0
- package/dist/lib/types/LayoutBox.js +20 -0
- package/dist/lib/types/LineBreakMode.d.ts +2 -0
- package/dist/lib/types/LineBreakMode.d.ts.map +1 -0
- package/dist/lib/types/LineBreakMode.js +20 -0
- package/dist/lib/types/MarginOptions.d.ts +7 -0
- package/dist/lib/types/MarginOptions.d.ts.map +1 -0
- package/dist/lib/types/MarginOptions.js +20 -0
- package/dist/lib/types/NodeElement.d.ts +7 -0
- package/dist/lib/types/NodeElement.d.ts.map +1 -0
- package/dist/lib/types/NodeElement.js +20 -0
- package/dist/lib/types/PaperFormat.d.ts +12 -0
- package/dist/lib/types/PaperFormat.d.ts.map +1 -0
- package/dist/lib/types/PaperFormat.js +33 -0
- package/dist/lib/types/PdfOptions.d.ts +10 -0
- package/dist/lib/types/PdfOptions.d.ts.map +1 -0
- package/dist/lib/types/PdfOptions.js +20 -0
- package/dist/lib/types/TextSegment.d.ts +7 -0
- package/dist/lib/types/TextSegment.d.ts.map +1 -0
- package/dist/lib/types/TextSegment.js +20 -0
- package/dist/lib/types/TextTransform.d.ts +2 -0
- package/dist/lib/types/TextTransform.d.ts.map +1 -0
- package/dist/lib/types/TextTransform.js +20 -0
- package/dist/lib/types/TextType.d.ts +2 -0
- package/dist/lib/types/TextType.d.ts.map +1 -0
- package/dist/lib/types/TextType.js +20 -0
- package/dist/lib/types/VerticalTextAlignment.d.ts +2 -0
- package/dist/lib/types/VerticalTextAlignment.d.ts.map +1 -0
- package/dist/lib/types/VerticalTextAlignment.js +20 -0
- package/dist/lib/types/index.d.ts +14 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/index.js +23 -0
- package/dist/program.d.ts +5 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +116 -0
- package/package.json +76 -0
- package/singleton/Courier-Bold.afm +342 -0
- package/singleton/Courier-BoldOblique.afm +342 -0
- package/singleton/Courier-Oblique.afm +342 -0
- package/singleton/Courier.afm +342 -0
- package/singleton/Helvetica-Bold.afm +2827 -0
- package/singleton/Helvetica-BoldOblique.afm +2827 -0
- package/singleton/Helvetica-Oblique.afm +3051 -0
- package/singleton/Helvetica.afm +3051 -0
- package/singleton/Symbol.afm +213 -0
- package/singleton/Times-Bold.afm +2588 -0
- package/singleton/Times-BoldItalic.afm +2384 -0
- package/singleton/Times-Italic.afm +2667 -0
- package/singleton/Times-Roman.afm +2419 -0
- package/singleton/ZapfDingbats.afm +225 -0
- package/singleton/index.js +101612 -0
- package/singleton/sRGB_IEC61966_2_1.icc +0 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.calculateTableColumnWidths = calculateTableColumnWidths;
|
|
22
|
+
function calculateTableColumnWidths(doc, rows, tableWidth) {
|
|
23
|
+
const columnCount = Math.max(...rows.map((r) => r.children.filter((c) => typeof c !== 'string').length));
|
|
24
|
+
const widths = new Array(columnCount).fill(0);
|
|
25
|
+
const fills = new Array(columnCount).fill(1);
|
|
26
|
+
// Primeiro pass:
|
|
27
|
+
// pega Width fixa e Fill
|
|
28
|
+
for (const row of rows) {
|
|
29
|
+
const cells = row.children.filter((c) => typeof c !== 'string');
|
|
30
|
+
cells.forEach((cell, index) => {
|
|
31
|
+
if (cell.props.Width) {
|
|
32
|
+
widths[index] = Math.max(widths[index], cell.props.Width);
|
|
33
|
+
}
|
|
34
|
+
fills[index] =
|
|
35
|
+
cell.props.Fill || fills[index];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const fixedWidth = widths.reduce((a, b) => a + b, 0);
|
|
39
|
+
const flexibleColumns = widths.map((w, i) => ({
|
|
40
|
+
index: i,
|
|
41
|
+
fill: fills[i],
|
|
42
|
+
flexible: w === 0,
|
|
43
|
+
}));
|
|
44
|
+
const totalFill = flexibleColumns
|
|
45
|
+
.filter((c) => c.flexible)
|
|
46
|
+
.reduce((acc, c) => acc + c.fill, 0);
|
|
47
|
+
const remainingWidth = tableWidth - fixedWidth;
|
|
48
|
+
for (const column of flexibleColumns) {
|
|
49
|
+
if (!column.flexible) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
widths[column.index] =
|
|
53
|
+
remainingWidth *
|
|
54
|
+
(column.fill / totalFill);
|
|
55
|
+
}
|
|
56
|
+
return widths;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cmToPt.d.ts","sourceRoot":"","sources":["../../../lib/common/cmToPt.ts"],"names":[],"mappings":"AAmBA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAiBrD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.cmToPt = cmToPt;
|
|
22
|
+
function cmToPt(value) {
|
|
23
|
+
if (typeof value == 'number')
|
|
24
|
+
return value;
|
|
25
|
+
if (value.endsWith('cm')) {
|
|
26
|
+
return parseFloat(value) * 28.3465;
|
|
27
|
+
}
|
|
28
|
+
if (value.endsWith('mm')) {
|
|
29
|
+
return parseFloat(value) * 72 / 25.4;
|
|
30
|
+
}
|
|
31
|
+
if (value.endsWith('in')) {
|
|
32
|
+
return parseFloat(value) * 72;
|
|
33
|
+
}
|
|
34
|
+
return Number(value);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractTableRows.d.ts","sourceRoot":"","sources":["../../../lib/common/extractTableRows.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,GAChB,WAAW,EAAE,CA+Bf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.extractTableRows = extractTableRows;
|
|
22
|
+
function extractTableRows(node) {
|
|
23
|
+
const rows = [];
|
|
24
|
+
for (const child of node.children) {
|
|
25
|
+
if (typeof child === 'string') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (child.type === 'TRow') {
|
|
29
|
+
rows.push(child);
|
|
30
|
+
}
|
|
31
|
+
if (child.type === 'THead' ||
|
|
32
|
+
child.type === 'TBody' ||
|
|
33
|
+
child.type === 'TFoot') {
|
|
34
|
+
for (const nested of child.children) {
|
|
35
|
+
if (typeof nested !== 'string' &&
|
|
36
|
+
nested.type === 'TRow') {
|
|
37
|
+
rows.push(nested);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return rows;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFontName.d.ts","sourceRoot":"","sources":["../../../lib/common/getFontName.ts"],"names":[],"mappings":"AAmBA,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,OAAO,UAejB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.getFontName = getFontName;
|
|
22
|
+
function getFontName(baseFont, bold, italic) {
|
|
23
|
+
if (bold && italic) {
|
|
24
|
+
return `${baseFont}-BoldOblique`;
|
|
25
|
+
}
|
|
26
|
+
if (bold) {
|
|
27
|
+
return `${baseFont}-Bold`;
|
|
28
|
+
}
|
|
29
|
+
if (italic) {
|
|
30
|
+
return `${baseFont}-Oblique`;
|
|
31
|
+
}
|
|
32
|
+
return baseFont;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMargin.d.ts","sourceRoot":"","sources":["../../../lib/common/getMargin.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS;;;;;EAejB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.getMargin = getMargin;
|
|
22
|
+
const cmToPt_1 = require("./cmToPt");
|
|
23
|
+
function getMargin(props) {
|
|
24
|
+
return {
|
|
25
|
+
top: (0, cmToPt_1.cmToPt)(props.MarginTop ?? 0),
|
|
26
|
+
right: (0, cmToPt_1.cmToPt)(props.MarginRight ?? 0),
|
|
27
|
+
bottom: (0, cmToPt_1.cmToPt)(props.MarginBottom ?? 0),
|
|
28
|
+
left: (0, cmToPt_1.cmToPt)(props.MarginLeft ?? 0),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPadding.d.ts","sourceRoot":"","sources":["../../../lib/common/getPadding.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS;;;;;EAiBjB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.getPadding = getPadding;
|
|
22
|
+
const cmToPt_1 = require("./cmToPt");
|
|
23
|
+
function getPadding(props) {
|
|
24
|
+
const padding = props.Padding || 0;
|
|
25
|
+
return {
|
|
26
|
+
top: (0, cmToPt_1.cmToPt)(props.PaddingTop ?? padding),
|
|
27
|
+
right: (0, cmToPt_1.cmToPt)(props.PaddingRight ?? padding),
|
|
28
|
+
bottom: (0, cmToPt_1.cmToPt)(props.PaddingBottom ?? padding),
|
|
29
|
+
left: (0, cmToPt_1.cmToPt)(props.PaddingLeft ?? padding),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSvgSize.d.ts","sourceRoot":"","sources":["../../../lib/common/getSvgSize.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM;;;EA6BrC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.getSvgSize = getSvgSize;
|
|
22
|
+
function getSvgSize(svg) {
|
|
23
|
+
const match = svg.match(/viewBox="([\d.-]+)\s+([\d.-]+)\s+([\d.-]+)\s+([\d.-]+)"/i);
|
|
24
|
+
if (match) {
|
|
25
|
+
return {
|
|
26
|
+
width: Number(match[3]),
|
|
27
|
+
height: Number(match[4]),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const widthMatch = svg.match(/width="([\d.]+)"/i);
|
|
31
|
+
const heightMatch = svg.match(/height="([\d.]+)"/i);
|
|
32
|
+
return {
|
|
33
|
+
width: widthMatch
|
|
34
|
+
? Number(widthMatch[1])
|
|
35
|
+
: 100,
|
|
36
|
+
height: heightMatch
|
|
37
|
+
? Number(heightMatch[1])
|
|
38
|
+
: 100,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeProps.d.ts","sourceRoot":"","sources":["../../../lib/common/mergeProps.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,wBAAgB,UAAU,CACxB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,GACjB,SAAS,CAKX"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.mergeProps = mergeProps;
|
|
22
|
+
function mergeProps(parent, current) {
|
|
23
|
+
return {
|
|
24
|
+
...parent,
|
|
25
|
+
...current,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../lib/common/normalize.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEjD,wBAAgB,SAAS,CACvB,KAAK,EAAE,GAAG,EAAE,EACZ,cAAc,GAAE,OAAO,CAAC,SAAS,CAAM,GACtC,WAAW,CA2Eb"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.normalize = normalize;
|
|
22
|
+
function normalize(nodes, inheritedProps = {}) {
|
|
23
|
+
const node = nodes[0];
|
|
24
|
+
const type = Object.keys(node).find((k) => k !== ':@');
|
|
25
|
+
const raw = node[type];
|
|
26
|
+
const props = {
|
|
27
|
+
FontFamily: inheritedProps.FontFamily,
|
|
28
|
+
FontSize: inheritedProps.FontSize,
|
|
29
|
+
AutoPageBreak: inheritedProps.AutoPageBreak,
|
|
30
|
+
LineHeight: inheritedProps.LineHeight,
|
|
31
|
+
};
|
|
32
|
+
if (node[':@']) {
|
|
33
|
+
for (const [key, value] of Object.entries(node[':@'])) {
|
|
34
|
+
;
|
|
35
|
+
props[key] =
|
|
36
|
+
value === 'true'
|
|
37
|
+
? true
|
|
38
|
+
: value === 'false'
|
|
39
|
+
? false
|
|
40
|
+
: isNaN(Number(value))
|
|
41
|
+
? value
|
|
42
|
+
: Number(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const nextInheritedProps = {
|
|
46
|
+
FontFamily: props.FontFamily,
|
|
47
|
+
AutoPageBreak: props.AutoPageBreak,
|
|
48
|
+
FontSize: props.FontSize,
|
|
49
|
+
};
|
|
50
|
+
const children = [];
|
|
51
|
+
for (const item of raw || []) {
|
|
52
|
+
const key = Object.keys(item)[0];
|
|
53
|
+
if (key === '#text') {
|
|
54
|
+
const value = String(item['#text'] ?? '').trim();
|
|
55
|
+
if (value) {
|
|
56
|
+
children.push(value);
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
children.push(normalize([item], nextInheritedProps));
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
type,
|
|
64
|
+
props,
|
|
65
|
+
children,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseInlineMarkdown.d.ts","sourceRoot":"","sources":["../../../lib/common/parseInlineMarkdown.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GACX,WAAW,EAAE,CA4Df"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.parseInlineMarkdown = parseInlineMarkdown;
|
|
22
|
+
function parseInlineMarkdown(text) {
|
|
23
|
+
const segments = [];
|
|
24
|
+
const regex = /(\*\*\*.*?\*\*\*|\*\*.*?\*\*|\*.*?\*)/g;
|
|
25
|
+
let lastIndex = 0;
|
|
26
|
+
for (const match of text.matchAll(regex)) {
|
|
27
|
+
const index = match.index || 0;
|
|
28
|
+
if (index > lastIndex) {
|
|
29
|
+
segments.push({
|
|
30
|
+
text: text.slice(lastIndex, index),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const token = match[0];
|
|
34
|
+
if (token.startsWith('***') &&
|
|
35
|
+
token.endsWith('***')) {
|
|
36
|
+
segments.push({
|
|
37
|
+
text: token.slice(3, -3),
|
|
38
|
+
bold: true,
|
|
39
|
+
italic: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (token.startsWith('**') &&
|
|
43
|
+
token.endsWith('**')) {
|
|
44
|
+
segments.push({
|
|
45
|
+
text: token.slice(2, -2),
|
|
46
|
+
bold: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else if (token.startsWith('*') &&
|
|
50
|
+
token.endsWith('*')) {
|
|
51
|
+
segments.push({
|
|
52
|
+
text: token.slice(1, -1),
|
|
53
|
+
italic: true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
lastIndex =
|
|
57
|
+
index + token.length;
|
|
58
|
+
}
|
|
59
|
+
if (lastIndex < text.length) {
|
|
60
|
+
segments.push({
|
|
61
|
+
text: text.slice(lastIndex),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return segments;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareText.d.ts","sourceRoot":"","sources":["../../../lib/common/prepareText.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,GAChB,MAAM,CAsBR"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.prepareText = prepareText;
|
|
22
|
+
function prepareText(node) {
|
|
23
|
+
let text = node.children
|
|
24
|
+
.filter((c) => typeof c === 'string')
|
|
25
|
+
.join(' ');
|
|
26
|
+
switch (node.props.TextTransform) {
|
|
27
|
+
case 'uppercase':
|
|
28
|
+
text = text.toUpperCase();
|
|
29
|
+
break;
|
|
30
|
+
case 'lowercase':
|
|
31
|
+
text = text.toLowerCase();
|
|
32
|
+
break;
|
|
33
|
+
case 'capitalize':
|
|
34
|
+
text = text.replace(/\b\w/g, (l) => l.toUpperCase());
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return text;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSize.d.ts","sourceRoot":"","sources":["../../../lib/common/resolveSize.ts"],"names":[],"mappings":"AAqBA,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAwBpB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 josedinizdev
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
*
|
|
15
|
+
* Author: José Diogo Caetano Diniz
|
|
16
|
+
* GitHub: https://github.com/josedinizdev
|
|
17
|
+
* Project: https://github.com/josedinizdev/PDFXml
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.resolveSize = resolveSize;
|
|
22
|
+
const cmToPt_1 = require("./cmToPt");
|
|
23
|
+
function resolveSize(value, parentSize) {
|
|
24
|
+
if (value == null) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'number') {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
const trimmed = value.trim();
|
|
32
|
+
if (trimmed.endsWith('%')) {
|
|
33
|
+
return (parentSize *
|
|
34
|
+
parseFloat(trimmed) /
|
|
35
|
+
100);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return (0, cmToPt_1.cmToPt)(trimmed);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncateWithEllipsis.d.ts","sourceRoot":"","sources":["../../../lib/common/truncateWithEllipsis.ts"],"names":[],"mappings":"AAmBA,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,CAAC,WAAW,EACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,gBAAgB,SAAI,GACnB,MAAM,CA8BR"}
|