@taskmagic/apps-pdf-co 0.0.1
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 +7 -0
- package/package.json +47 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +28 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/add-barcode-to-pdf.d.ts +15 -0
- package/src/lib/actions/add-barcode-to-pdf.js +148 -0
- package/src/lib/actions/add-barcode-to-pdf.js.map +1 -0
- package/src/lib/actions/add-image-to-pdf.d.ts +14 -0
- package/src/lib/actions/add-image-to-pdf.js +114 -0
- package/src/lib/actions/add-image-to-pdf.js.map +1 -0
- package/src/lib/actions/add-text-to-pdf.d.ts +21 -0
- package/src/lib/actions/add-text-to-pdf.js +149 -0
- package/src/lib/actions/add-text-to-pdf.js.map +1 -0
- package/src/lib/actions/convert-html-to-pdf.d.ts +14 -0
- package/src/lib/actions/convert-html-to-pdf.js +190 -0
- package/src/lib/actions/convert-html-to-pdf.js.map +1 -0
- package/src/lib/actions/convert-pdf-to-structured-format.d.ts +12 -0
- package/src/lib/actions/convert-pdf-to-structured-format.js +123 -0
- package/src/lib/actions/convert-pdf-to-structured-format.js.map +1 -0
- package/src/lib/actions/extract-tables-from-pdf.d.ts +11 -0
- package/src/lib/actions/extract-tables-from-pdf.js +103 -0
- package/src/lib/actions/extract-tables-from-pdf.js.map +1 -0
- package/src/lib/actions/extract-text-from-pdf.d.ts +8 -0
- package/src/lib/actions/extract-text-from-pdf.js +96 -0
- package/src/lib/actions/extract-text-from-pdf.js.map +1 -0
- package/src/lib/actions/index.d.ts +8 -0
- package/src/lib/actions/index.js +12 -0
- package/src/lib/actions/index.js.map +1 -0
- package/src/lib/actions/search-and-replace-text.d.ts +13 -0
- package/src/lib/actions/search-and-replace-text.js +99 -0
- package/src/lib/actions/search-and-replace-text.js.map +1 -0
- package/src/lib/auth.d.ts +1 -0
- package/src/lib/auth.js +10 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/props.d.ts +8 -0
- package/src/lib/common/props.js +33 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/types.d.ts +37 -0
- package/src/lib/common/types.js +3 -0
- package/src/lib/common/types.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-pdf-co",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@anthropic-ai/sdk": "0.33.1",
|
|
6
|
+
"@sinclair/typebox": "0.34.11",
|
|
7
|
+
"axios": "1.17.0",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"mime-types": "2.1.35",
|
|
11
|
+
"nanoid": "3.3.8",
|
|
12
|
+
"openai": "4.67.1",
|
|
13
|
+
"replicate": "0.34.1",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"zod": "3.25.76",
|
|
16
|
+
"@taskmagic/pieces-common": "0.4.4",
|
|
17
|
+
"@taskmagic/pieces-framework": "0.7.46",
|
|
18
|
+
"@taskmagic/shared": "0.10.171",
|
|
19
|
+
"tslib": "1.14.1"
|
|
20
|
+
},
|
|
21
|
+
"overrides": {
|
|
22
|
+
"cross-spawn": "7.0.6",
|
|
23
|
+
"elliptic": "^6.6.1",
|
|
24
|
+
"fast-xml-parser": "^4.4.1",
|
|
25
|
+
"protobufjs": "^7.5.5",
|
|
26
|
+
"tmp": "^0.2.4",
|
|
27
|
+
"koa": "^2.16.4",
|
|
28
|
+
"picomatch": "^4.0.4",
|
|
29
|
+
"langsmith": "^0.6.0",
|
|
30
|
+
"serialize-javascript": "^6.0.2",
|
|
31
|
+
"elevenlabs": {
|
|
32
|
+
"form-data": "^4.0.4"
|
|
33
|
+
},
|
|
34
|
+
"@tryfabric/martian": {
|
|
35
|
+
"@notionhq/client": "$@notionhq/client"
|
|
36
|
+
},
|
|
37
|
+
"vite": {
|
|
38
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"resolutions": {
|
|
42
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
43
|
+
},
|
|
44
|
+
"types": "./src/index.d.ts",
|
|
45
|
+
"main": "./src/index.js",
|
|
46
|
+
"type": "commonjs"
|
|
47
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pdfCo: import("@taskmagic/pieces-framework").Piece<import("@taskmagic/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdfCo = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
5
|
+
const shared_1 = require("@taskmagic/shared");
|
|
6
|
+
const actions_1 = require("./lib/actions");
|
|
7
|
+
const auth_1 = require("./lib/auth");
|
|
8
|
+
exports.pdfCo = (0, pieces_framework_1.createPiece)({
|
|
9
|
+
displayName: 'PDF.co',
|
|
10
|
+
description: 'Automate PDF conversion, editing, extraction',
|
|
11
|
+
minimumSupportedRelease: '0.30.0',
|
|
12
|
+
categories: [shared_1.PieceCategory.PRODUCTIVITY, shared_1.PieceCategory.CONTENT_AND_FILES],
|
|
13
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/pdf-co.png',
|
|
14
|
+
auth: auth_1.pdfCoAuth,
|
|
15
|
+
authors: ['onyedikachi-david', 'kishanprmr'],
|
|
16
|
+
actions: [
|
|
17
|
+
actions_1.addBarcodeToPdf,
|
|
18
|
+
actions_1.addImageToPdf,
|
|
19
|
+
actions_1.addTextToPdf,
|
|
20
|
+
actions_1.convertHtmlToPdf,
|
|
21
|
+
actions_1.convertPdfToStructuredFormat,
|
|
22
|
+
actions_1.extractTablesFromPdf,
|
|
23
|
+
actions_1.extractTextFromPdf,
|
|
24
|
+
actions_1.searchAndReplaceText,
|
|
25
|
+
],
|
|
26
|
+
triggers: [],
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/pdf-co/src/index.ts"],"names":[],"mappings":";;;AAAA,kEAA0D;AAC1D,8CAAkD;AAClD,2CASuB;AACvB,qCAAuC;AAE1B,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,8CAA8C;IAC3D,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,EAAE,sBAAa,CAAC,iBAAiB,CAAC;IACzE,OAAO,EAAE,gDAAgD;IACzD,IAAI,EAAE,gBAAS;IACf,OAAO,EAAE,CAAC,mBAAmB,EAAE,YAAY,CAAC;IAC5C,OAAO,EAAE;QACR,yBAAe;QACf,uBAAa;QACb,sBAAY;QACZ,0BAAgB;QAChB,sCAA4B;QAC5B,8BAAoB;QACpB,4BAAkB;QAClB,8BAAoB;KACpB;IACD,QAAQ,EAAE,EAAE;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const addBarcodeToPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
fileName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
expiration: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
4
|
+
pdfPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
httpUsername: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
httpPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
sourcePdfUrl: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
barcodeValue: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
barcodeType: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, true>;
|
|
10
|
+
x: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
11
|
+
y: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
12
|
+
width: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
13
|
+
height: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
14
|
+
pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addBarcodeToPdf = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const props_1 = require("../common/props");
|
|
9
|
+
// Supported Barcode Types
|
|
10
|
+
const barcodeTypes = [
|
|
11
|
+
{ label: 'QR Code (Default)', value: 'QRCode' },
|
|
12
|
+
{ label: 'DataMatrix', value: 'DataMatrix' },
|
|
13
|
+
{ label: 'Code 128', value: 'Code128' },
|
|
14
|
+
{ label: 'Code 39', value: 'Code39' },
|
|
15
|
+
{ label: 'PDF417', value: 'PDF417' },
|
|
16
|
+
{ label: 'EAN-13', value: 'EAN13' },
|
|
17
|
+
{ label: 'UPC-A', value: 'UPCA' },
|
|
18
|
+
];
|
|
19
|
+
exports.addBarcodeToPdf = (0, pieces_framework_1.createAction)({
|
|
20
|
+
name: 'add_barcode_to_pdf',
|
|
21
|
+
displayName: 'Add Barcode to PDF',
|
|
22
|
+
description: 'Generate a barcode image and add it to a specific location on a PDF.',
|
|
23
|
+
auth: auth_1.pdfCoAuth,
|
|
24
|
+
props: Object.assign({ sourcePdfUrl: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'Source PDF URL',
|
|
26
|
+
description: 'URL of the PDF file to add the barcode to.',
|
|
27
|
+
required: true,
|
|
28
|
+
}), barcodeValue: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Barcode Value',
|
|
30
|
+
description: 'The text or data to encode in the barcode.',
|
|
31
|
+
required: true,
|
|
32
|
+
}), barcodeType: pieces_framework_1.Property.StaticDropdown({
|
|
33
|
+
displayName: 'Barcode Type',
|
|
34
|
+
description: 'Select the type of barcode to generate.',
|
|
35
|
+
required: true,
|
|
36
|
+
options: { disabled: false, options: barcodeTypes, placeholder: 'Select Barcode Type' },
|
|
37
|
+
}), x: pieces_framework_1.Property.Number({
|
|
38
|
+
displayName: 'X Coordinate',
|
|
39
|
+
description: 'X coordinate (from top-left corner) to place the barcode.',
|
|
40
|
+
required: true,
|
|
41
|
+
}), y: pieces_framework_1.Property.Number({
|
|
42
|
+
displayName: 'Y Coordinate',
|
|
43
|
+
description: 'Y coordinate (from top-left corner) to place the barcode.',
|
|
44
|
+
required: true,
|
|
45
|
+
}), width: pieces_framework_1.Property.Number({
|
|
46
|
+
displayName: 'Width (optional)',
|
|
47
|
+
description: 'Optional width for the barcode image on the PDF (in points). Aspect ratio is kept by default.',
|
|
48
|
+
required: false,
|
|
49
|
+
}), height: pieces_framework_1.Property.Number({
|
|
50
|
+
displayName: 'Height (optional)',
|
|
51
|
+
description: 'Optional height for the barcode image on the PDF (in points). Aspect ratio is kept by default.',
|
|
52
|
+
required: false,
|
|
53
|
+
}), pages: pieces_framework_1.Property.ShortText({
|
|
54
|
+
displayName: 'Pages',
|
|
55
|
+
description: 'Comma-separated page numbers or ranges to add the barcode (e.g., "0,2,5-10"). Leave empty for all pages.',
|
|
56
|
+
required: false,
|
|
57
|
+
}) }, props_1.commonProps),
|
|
58
|
+
run(context) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const { auth, propsValue } = context;
|
|
62
|
+
const { sourcePdfUrl, barcodeValue, barcodeType, x, y, width, height, pages, fileName, pdfPassword, httpPassword, httpUsername, expiration, } = propsValue;
|
|
63
|
+
let barcodeImageUrl = '';
|
|
64
|
+
// --- Step 1: Generate Barcode ---
|
|
65
|
+
const generateBarcodeBody = {
|
|
66
|
+
value: barcodeValue,
|
|
67
|
+
type: barcodeType,
|
|
68
|
+
async: false,
|
|
69
|
+
inline: false, // Need the URL
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
const generateResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
73
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
74
|
+
url: `${props_1.BASE_URL}/barcode/generate`,
|
|
75
|
+
headers: {
|
|
76
|
+
'x-api-key': auth,
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
},
|
|
79
|
+
body: generateBarcodeBody,
|
|
80
|
+
});
|
|
81
|
+
if (generateResponse.body.error) {
|
|
82
|
+
const errorBody = generateResponse.body;
|
|
83
|
+
throw new Error(`PDF.co Barcode Generation Error: Status ${errorBody.status}. ${errorBody.message || 'Unknown error.'}`);
|
|
84
|
+
}
|
|
85
|
+
barcodeImageUrl = generateResponse.body.url;
|
|
86
|
+
if (!barcodeImageUrl) {
|
|
87
|
+
throw new Error('Failed to get barcode image URL from PDF.co response.');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (error instanceof pieces_common_1.HttpError) {
|
|
92
|
+
const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
|
|
93
|
+
throw new Error(`HTTP Error generating barcode: ${error.message}. ${(responseBody === null || responseBody === void 0 ? void 0 : responseBody.message)
|
|
94
|
+
? 'Server message: ' + responseBody.message
|
|
95
|
+
: 'Raw response: ' + JSON.stringify(responseBody)}`);
|
|
96
|
+
}
|
|
97
|
+
throw error; // Re-throw other errors
|
|
98
|
+
}
|
|
99
|
+
// --- Step 2: Add Barcode Image to PDF ---
|
|
100
|
+
const imageAnnotation = {
|
|
101
|
+
url: barcodeImageUrl,
|
|
102
|
+
x: x,
|
|
103
|
+
y: y,
|
|
104
|
+
width,
|
|
105
|
+
height,
|
|
106
|
+
pages,
|
|
107
|
+
};
|
|
108
|
+
const addImageBody = {
|
|
109
|
+
url: sourcePdfUrl,
|
|
110
|
+
images: [imageAnnotation],
|
|
111
|
+
async: false,
|
|
112
|
+
inline: false, // Get final PDF URL
|
|
113
|
+
name: fileName,
|
|
114
|
+
expiration,
|
|
115
|
+
httppassword: httpPassword,
|
|
116
|
+
httpusername: httpUsername,
|
|
117
|
+
password: pdfPassword,
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
const addResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
121
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
122
|
+
url: `${props_1.BASE_URL}/pdf/edit/add`,
|
|
123
|
+
headers: {
|
|
124
|
+
'x-api-key': auth,
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
body: addImageBody,
|
|
128
|
+
});
|
|
129
|
+
if (addResponse.body.error) {
|
|
130
|
+
const errorBody = addResponse.body;
|
|
131
|
+
throw new Error(`PDF.co Add Image Error: Status ${errorBody.status}. ${errorBody.message || 'Unknown error.'}`);
|
|
132
|
+
}
|
|
133
|
+
// Return the successful response containing the final PDF URL
|
|
134
|
+
return addResponse.body;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error instanceof pieces_common_1.HttpError) {
|
|
138
|
+
const responseBody = (_b = error.response) === null || _b === void 0 ? void 0 : _b.body;
|
|
139
|
+
throw new Error(`HTTP Error adding barcode image to PDF: ${error.message}. ${(responseBody === null || responseBody === void 0 ? void 0 : responseBody.message)
|
|
140
|
+
? 'Server message: ' + responseBody.message
|
|
141
|
+
: 'Raw response: ' + JSON.stringify(responseBody)}`);
|
|
142
|
+
}
|
|
143
|
+
throw error; // Re-throw other errors
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=add-barcode-to-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-barcode-to-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/add-barcode-to-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqF;AACrF,4DAA6E;AAO7E,kCAAoC;AACpC,2CAAwD;AAwBxD,0BAA0B;AAC1B,MAAM,YAAY,GAA6B;IAC9C,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC/C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE;IACvC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE;IACrC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;IACnC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;CACjC,CAAC;AAEW,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,sEAAsE;IACnF,IAAI,EAAE,gBAAS;IACf,KAAK,kBACJ,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,eAAe;YAC5B,WAAW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AY,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAsC,CAAC;oBAC5E,MAAM,IAAI,KAAK,CACd,2CAA2C,KAAK,CAAC,OAAO,KACvD,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO;wBACpB,CAAC,CAAC,kBAAkB,GAAG,YAAY,CAAC,OAAO;wBAC3C,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAClD,EAAE,CACF,CAAC;gBACH,CAAC;gBACD,MAAM,KAAK,CAAC,CAAC,wBAAwB;YACtC,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const addImageToPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
fileName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
expiration: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
4
|
+
pdfPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
httpUsername: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
httpPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
url: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
imageUrl: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
xCoordinate: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
10
|
+
yCoordinate: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
11
|
+
width: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
12
|
+
height: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
13
|
+
pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addImageToPdf = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const props_1 = require("../common/props");
|
|
9
|
+
exports.addImageToPdf = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'add_image_to_pdf',
|
|
11
|
+
displayName: 'Add Image to PDF',
|
|
12
|
+
description: 'Add image to a PDF document.',
|
|
13
|
+
auth: auth_1.pdfCoAuth,
|
|
14
|
+
props: Object.assign({ url: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Source PDF URL',
|
|
16
|
+
description: 'URL of the PDF file to modify.',
|
|
17
|
+
required: true,
|
|
18
|
+
}), imageUrl: pieces_framework_1.Property.ShortText({
|
|
19
|
+
displayName: 'Image URL',
|
|
20
|
+
required: true,
|
|
21
|
+
}), xCoordinate: pieces_framework_1.Property.Number({
|
|
22
|
+
displayName: 'X Coordinate',
|
|
23
|
+
description: 'X coordinate (from top-left corner) to place the image.',
|
|
24
|
+
required: true,
|
|
25
|
+
}), yCoordinate: pieces_framework_1.Property.Number({
|
|
26
|
+
displayName: 'Y Coordinate',
|
|
27
|
+
required: true,
|
|
28
|
+
description: 'Y coordinate (from top-left corner) to place the image.',
|
|
29
|
+
}), width: pieces_framework_1.Property.Number({
|
|
30
|
+
displayName: 'Width',
|
|
31
|
+
description: 'Optional width for the image on the PDF (in points). Aspect ratio is kept by default.',
|
|
32
|
+
required: false,
|
|
33
|
+
}), height: pieces_framework_1.Property.Number({
|
|
34
|
+
displayName: 'Height',
|
|
35
|
+
description: 'Optional height for the image on the PDF (in points). Aspect ratio is kept by default.',
|
|
36
|
+
required: false,
|
|
37
|
+
}), pages: pieces_framework_1.Property.ShortText({
|
|
38
|
+
displayName: 'Target Pages',
|
|
39
|
+
description: 'Specify page indices as comma-separated values or ranges to process (e.g. "0, 1, 2-" or "1, 2, 3-7").',
|
|
40
|
+
required: false,
|
|
41
|
+
}) }, props_1.commonProps),
|
|
42
|
+
run(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
var _a;
|
|
45
|
+
const { auth, propsValue } = context;
|
|
46
|
+
const { url, imageUrl, fileName, pdfPassword, xCoordinate, pages, yCoordinate, width, height, expiration, httpPassword, httpUsername, } = propsValue;
|
|
47
|
+
const imageAnnotationPayload = {
|
|
48
|
+
url: imageUrl,
|
|
49
|
+
x: xCoordinate,
|
|
50
|
+
y: yCoordinate,
|
|
51
|
+
pages,
|
|
52
|
+
height,
|
|
53
|
+
width,
|
|
54
|
+
};
|
|
55
|
+
const requestBody = {
|
|
56
|
+
url: url,
|
|
57
|
+
images: [imageAnnotationPayload],
|
|
58
|
+
async: false,
|
|
59
|
+
name: fileName,
|
|
60
|
+
expiration,
|
|
61
|
+
httppassword: httpPassword,
|
|
62
|
+
httpusername: httpUsername,
|
|
63
|
+
password: pdfPassword,
|
|
64
|
+
inline: false,
|
|
65
|
+
};
|
|
66
|
+
try {
|
|
67
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
68
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
69
|
+
url: `${props_1.BASE_URL}/pdf/edit/add`,
|
|
70
|
+
headers: {
|
|
71
|
+
'x-api-key': auth,
|
|
72
|
+
'Content-Type': 'application/json',
|
|
73
|
+
},
|
|
74
|
+
body: requestBody,
|
|
75
|
+
});
|
|
76
|
+
if (response.body.error) {
|
|
77
|
+
const errorBody = response.body;
|
|
78
|
+
let errorMessage = `PDF.co API Error (Add Image): Status ${errorBody.status}.`;
|
|
79
|
+
if (errorBody.message) {
|
|
80
|
+
errorMessage += ` Message: ${errorBody.message}.`;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
errorMessage += ` An unspecified error occurred.`;
|
|
84
|
+
}
|
|
85
|
+
errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
|
|
86
|
+
throw new Error(errorMessage);
|
|
87
|
+
}
|
|
88
|
+
const successBody = response.body;
|
|
89
|
+
return {
|
|
90
|
+
outputUrl: successBody.url,
|
|
91
|
+
pageCount: successBody.pageCount,
|
|
92
|
+
outputName: successBody.name,
|
|
93
|
+
creditsUsed: successBody.credits,
|
|
94
|
+
remainingCredits: successBody.remainingCredits,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof pieces_common_1.HttpError) {
|
|
99
|
+
const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
|
|
100
|
+
let detailedMessage = `HTTP Error calling PDF.co API (Add Image): ${error.message}.`;
|
|
101
|
+
if (responseBody && responseBody.message) {
|
|
102
|
+
detailedMessage += ` Server message: ${responseBody.message}.`;
|
|
103
|
+
}
|
|
104
|
+
else if (responseBody) {
|
|
105
|
+
detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
|
|
106
|
+
}
|
|
107
|
+
throw new Error(detailedMessage);
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=add-image-to-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-image-to-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/add-image-to-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAA6E;AAO7E,kCAAoC;AACpC,2CAAwD;AAE3C,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,8BAA8B;IAC3C,IAAI,EAAE,gBAAS;IACf,KAAK,kBACJ,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW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AAI;oBAC5B,WAAW,EAAE,WAAW,CAAC,OAAO;oBAChC,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;iBAC9C,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,KAAK,YAAY,yBAAS,EAAE,CAAC;oBAChC,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAsC,CAAC;oBAC5E,IAAI,eAAe,GAAG,8CAA8C,KAAK,CAAC,OAAO,GAAG,CAAC;oBACrF,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBAC1C,eAAe,IAAI,oBAAoB,YAAY,CAAC,OAAO,GAAG,CAAC;oBAChE,CAAC;yBAAM,IAAI,YAAY,EAAE,CAAC;wBACzB,eAAe,IAAI,qBAAqB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC;oBACzE,CAAC;oBACD,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const addTextToPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
fileName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
expiration: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
4
|
+
pdfPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
httpUsername: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
httpPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
url: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
text: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
9
|
+
xCoordinate: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
10
|
+
yCoordinate: import("@taskmagic/pieces-framework").NumberProperty<true>;
|
|
11
|
+
fontSize: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
12
|
+
color: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
fontBold: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
14
|
+
fontStrikeout: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
15
|
+
fontUnderline: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
16
|
+
fontName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
textBoxHeight: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
19
|
+
textBoxWidth: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
20
|
+
textBoxAlignment: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addTextToPdf = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const props_1 = require("../common/props");
|
|
9
|
+
exports.addTextToPdf = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'add_text_to_pdf',
|
|
11
|
+
displayName: 'Add Text to PDF',
|
|
12
|
+
description: 'Adds text to PDF.',
|
|
13
|
+
auth: auth_1.pdfCoAuth,
|
|
14
|
+
props: Object.assign({ url: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Source PDF URL',
|
|
16
|
+
description: 'URL of the PDF file to modify.',
|
|
17
|
+
required: true,
|
|
18
|
+
}), text: pieces_framework_1.Property.LongText({
|
|
19
|
+
displayName: 'Text to Add',
|
|
20
|
+
required: true,
|
|
21
|
+
}), xCoordinate: pieces_framework_1.Property.Number({
|
|
22
|
+
displayName: 'X Coordinate',
|
|
23
|
+
required: true,
|
|
24
|
+
}), yCoordinate: pieces_framework_1.Property.Number({
|
|
25
|
+
displayName: 'Y Coordinate',
|
|
26
|
+
required: true,
|
|
27
|
+
}), fontSize: pieces_framework_1.Property.Number({
|
|
28
|
+
displayName: 'Font Size',
|
|
29
|
+
required: false,
|
|
30
|
+
}), color: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'Color',
|
|
32
|
+
defaultValue: '#000000',
|
|
33
|
+
required: false,
|
|
34
|
+
}), fontBold: pieces_framework_1.Property.Checkbox({
|
|
35
|
+
displayName: 'Bold Font ?',
|
|
36
|
+
required: false,
|
|
37
|
+
}), fontStrikeout: pieces_framework_1.Property.Checkbox({
|
|
38
|
+
displayName: 'Stikeout Font ?',
|
|
39
|
+
required: false,
|
|
40
|
+
}), fontUnderline: pieces_framework_1.Property.Checkbox({
|
|
41
|
+
displayName: 'Underline Font ?',
|
|
42
|
+
required: false,
|
|
43
|
+
}), fontName: pieces_framework_1.Property.ShortText({
|
|
44
|
+
displayName: 'Font Name',
|
|
45
|
+
defaultValue: 'Arial',
|
|
46
|
+
required: false,
|
|
47
|
+
}), pages: pieces_framework_1.Property.ShortText({
|
|
48
|
+
displayName: 'Target Pages',
|
|
49
|
+
description: 'Specify page indices as comma-separated values or ranges to process (e.g. "0, 1, 2-" or "1, 2, 3-7").',
|
|
50
|
+
required: false,
|
|
51
|
+
}), textBoxHeight: pieces_framework_1.Property.Number({
|
|
52
|
+
displayName: 'Text Box Height',
|
|
53
|
+
required: false,
|
|
54
|
+
}), textBoxWidth: pieces_framework_1.Property.Number({
|
|
55
|
+
displayName: 'Text Box Width',
|
|
56
|
+
required: false,
|
|
57
|
+
}), textBoxAlignment: pieces_framework_1.Property.StaticDropdown({
|
|
58
|
+
displayName: 'Text Box Alignment',
|
|
59
|
+
required: false,
|
|
60
|
+
defaultValue: 'left',
|
|
61
|
+
options: {
|
|
62
|
+
disabled: false,
|
|
63
|
+
options: [
|
|
64
|
+
{ label: 'left', value: 'left' },
|
|
65
|
+
{ label: 'right', value: 'right' },
|
|
66
|
+
{ label: 'center', value: 'center' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
}) }, props_1.commonProps),
|
|
70
|
+
run(context) {
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a;
|
|
73
|
+
const { auth, propsValue } = context;
|
|
74
|
+
const { url, xCoordinate, yCoordinate, fontSize, fontName, fontBold, fontStrikeout, fontUnderline, color, pages, textBoxAlignment, textBoxHeight, textBoxWidth, text, fileName, pdfPassword, httpPassword, httpUsername, expiration, } = propsValue;
|
|
75
|
+
const textAnnotationPayload = {
|
|
76
|
+
x: xCoordinate,
|
|
77
|
+
y: yCoordinate,
|
|
78
|
+
text,
|
|
79
|
+
type: 'text',
|
|
80
|
+
color,
|
|
81
|
+
pages,
|
|
82
|
+
width: textBoxWidth,
|
|
83
|
+
height: textBoxHeight,
|
|
84
|
+
alignment: textBoxAlignment,
|
|
85
|
+
size: fontSize,
|
|
86
|
+
fontName,
|
|
87
|
+
fontBold,
|
|
88
|
+
fontStrikeout,
|
|
89
|
+
fontUnderline,
|
|
90
|
+
};
|
|
91
|
+
const requestBody = {
|
|
92
|
+
url: url,
|
|
93
|
+
annotations: [textAnnotationPayload],
|
|
94
|
+
async: false,
|
|
95
|
+
name: fileName,
|
|
96
|
+
expiration,
|
|
97
|
+
httppassword: httpPassword,
|
|
98
|
+
httpusername: httpUsername,
|
|
99
|
+
password: pdfPassword,
|
|
100
|
+
};
|
|
101
|
+
try {
|
|
102
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
103
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
104
|
+
url: `${props_1.BASE_URL}/pdf/edit/add`,
|
|
105
|
+
headers: {
|
|
106
|
+
'x-api-key': auth,
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
},
|
|
109
|
+
body: requestBody,
|
|
110
|
+
});
|
|
111
|
+
if (response.body.error) {
|
|
112
|
+
const errorBody = response.body;
|
|
113
|
+
let errorMessage = `PDF.co API Error (Add Text): Status ${errorBody.status}.`;
|
|
114
|
+
if (errorBody.message) {
|
|
115
|
+
errorMessage += ` Message: ${errorBody.message}.`;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
errorMessage += ` An unspecified error occurred.`;
|
|
119
|
+
}
|
|
120
|
+
errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
|
|
121
|
+
throw new Error(errorMessage);
|
|
122
|
+
}
|
|
123
|
+
const successBody = response.body;
|
|
124
|
+
return {
|
|
125
|
+
outputUrl: successBody.url,
|
|
126
|
+
pageCount: successBody.pageCount,
|
|
127
|
+
outputName: successBody.name,
|
|
128
|
+
creditsUsed: successBody.credits,
|
|
129
|
+
remainingCredits: successBody.remainingCredits,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (error instanceof pieces_common_1.HttpError) {
|
|
134
|
+
const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
|
|
135
|
+
let detailedMessage = `HTTP Error calling PDF.co API (Add Text): ${error.message}.`;
|
|
136
|
+
if (responseBody && responseBody.message) {
|
|
137
|
+
detailedMessage += ` Server message: ${responseBody.message}.`;
|
|
138
|
+
}
|
|
139
|
+
else if (responseBody) {
|
|
140
|
+
detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
|
|
141
|
+
}
|
|
142
|
+
throw new Error(detailedMessage);
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=add-text-to-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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Y,IAAI,iCAAiC,CAAC;oBACnD,CAAC;oBACD,YAAY,IAAI,kBAAkB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC9D,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;gBAC/B,CAAC;gBAED,MAAM,WAAW,GAAG,QAAQ,CAAC,IAA4B,CAAC;gBAC1D,OAAO;oBACN,SAAS,EAAE,WAAW,CAAC,GAAG;oBAC1B,SAAS,EAAE,WAAW,CAAC,SAAS;oBAChC,UAAU,EAAE,WAAW,CAAC,IAAI;oBAC5B,WAAW,EAAE,WAAW,CAAC,OAAO;oBAChC,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;iBAC9C,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,KAAK,YAAY,yBAAS,EAAE,CAAC;oBAChC,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAsC,CAAC;oBAC5E,IAAI,eAAe,GAAG,6CAA6C,KAAK,CAAC,OAAO,GAAG,CAAC;oBACpF,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBAC1C,eAAe,IAAI,oBAAoB,YAAY,CAAC,OAAO,GAAG,CAAC;oBAChE,CAAC;yBAAM,IAAI,YAAY,EAAE,CAAC;wBACzB,eAAe,IAAI,qBAAqB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC;oBACzE,CAAC;oBACD,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;gBAClC,CAAC;gBACD,MAAM,KAAK,CAAC;YACb,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const convertHtmlToPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
html: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
3
|
+
name: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
margins: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
paperSize: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
6
|
+
orientation: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
7
|
+
printBackground: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
8
|
+
mediaType: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
9
|
+
header: import("@taskmagic/pieces-framework").LongTextProperty<false>;
|
|
10
|
+
footer: import("@taskmagic/pieces-framework").LongTextProperty<false>;
|
|
11
|
+
doNotWaitFullLoad: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
expiration: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
13
|
+
profiles: import("@taskmagic/pieces-framework").JsonProperty<false>;
|
|
14
|
+
}>;
|