@taskmagic/apps-pdf4me 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 +3 -0
- package/src/index.js +46 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/compress-pdf.d.ts +4 -0
- package/src/lib/actions/compress-pdf.js +60 -0
- package/src/lib/actions/compress-pdf.js.map +1 -0
- package/src/lib/actions/convert-to-pdf.d.ts +4 -0
- package/src/lib/actions/convert-to-pdf.js +46 -0
- package/src/lib/actions/convert-to-pdf.js.map +1 -0
- package/src/lib/actions/merge-pdfs.d.ts +5 -0
- package/src/lib/actions/merge-pdfs.js +55 -0
- package/src/lib/actions/merge-pdfs.js.map +1 -0
- package/src/lib/actions/pdf-to-image.d.ts +6 -0
- package/src/lib/actions/pdf-to-image.js +77 -0
- package/src/lib/actions/pdf-to-image.js.map +1 -0
- package/src/lib/actions/pdf-to-word.d.ts +7 -0
- package/src/lib/actions/pdf-to-word.js +99 -0
- package/src/lib/actions/pdf-to-word.js.map +1 -0
- package/src/lib/actions/protect-pdf.d.ts +5 -0
- package/src/lib/actions/protect-pdf.js +65 -0
- package/src/lib/actions/protect-pdf.js.map +1 -0
- package/src/lib/actions/split-pdf.d.ts +5 -0
- package/src/lib/actions/split-pdf.js +96 -0
- package/src/lib/actions/split-pdf.js.map +1 -0
- package/src/lib/auth.d.ts +1 -0
- package/src/lib/auth.js +13 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/index.d.ts +19 -0
- package/src/lib/common/index.js +49 -0
- package/src/lib/common/index.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-pdf4me",
|
|
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
package/src/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdf4me = exports.pdf4meAuth = 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 shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const auth_1 = require("./lib/auth");
|
|
9
|
+
Object.defineProperty(exports, "pdf4meAuth", { enumerable: true, get: function () { return auth_1.pdf4meAuth; } });
|
|
10
|
+
const common_1 = require("./lib/common");
|
|
11
|
+
const convert_to_pdf_1 = require("./lib/actions/convert-to-pdf");
|
|
12
|
+
const merge_pdfs_1 = require("./lib/actions/merge-pdfs");
|
|
13
|
+
const split_pdf_1 = require("./lib/actions/split-pdf");
|
|
14
|
+
const compress_pdf_1 = require("./lib/actions/compress-pdf");
|
|
15
|
+
const protect_pdf_1 = require("./lib/actions/protect-pdf");
|
|
16
|
+
const pdf_to_word_1 = require("./lib/actions/pdf-to-word");
|
|
17
|
+
const pdf_to_image_1 = require("./lib/actions/pdf-to-image");
|
|
18
|
+
exports.pdf4me = (0, pieces_framework_1.createPiece)({
|
|
19
|
+
displayName: 'PDF4me',
|
|
20
|
+
description: 'Convert, merge, split, compress, and protect PDF documents.',
|
|
21
|
+
minimumSupportedRelease: '0.30.0',
|
|
22
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/pdf4me.png',
|
|
23
|
+
categories: [shared_1.PieceCategory.CONTENT_AND_FILES],
|
|
24
|
+
auth: auth_1.pdf4meAuth,
|
|
25
|
+
authors: ['onyedikachi-david'],
|
|
26
|
+
actions: [
|
|
27
|
+
convert_to_pdf_1.convertToPdfAction,
|
|
28
|
+
merge_pdfs_1.mergePdfsAction,
|
|
29
|
+
split_pdf_1.splitPdfAction,
|
|
30
|
+
compress_pdf_1.compressPdfAction,
|
|
31
|
+
protect_pdf_1.protectPdfAction,
|
|
32
|
+
pdf_to_word_1.pdfToWordAction,
|
|
33
|
+
pdf_to_image_1.pdfToImageAction,
|
|
34
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
35
|
+
baseUrl: () => common_1.pdf4meCommon.BASE_URL,
|
|
36
|
+
auth: auth_1.pdf4meAuth,
|
|
37
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
return ({
|
|
39
|
+
Authorization: auth,
|
|
40
|
+
});
|
|
41
|
+
}),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
triggers: [],
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/pdf4me/src/index.ts"],"names":[],"mappings":";;;;AAAA,kEAA0D;AAC1D,4DAAqE;AACrE,8CAAkD;AAClD,qCAAwC;AAU/B,2FAVA,iBAAU,OAUA;AATnB,yCAA4C;AAC5C,iEAAkE;AAClE,yDAA2D;AAC3D,uDAAyD;AACzD,6DAA+D;AAC/D,2DAA6D;AAC7D,2DAA4D;AAC5D,6DAA8D;AAIjD,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,6DAA6D;IAC1E,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,CAAC,sBAAa,CAAC,iBAAiB,CAAC;IAC7C,IAAI,EAAE,iBAAU;IAChB,OAAO,EAAE,CAAC,mBAAmB,CAAC;IAC9B,OAAO,EAAE;QACP,mCAAkB;QAClB,4BAAe;QACf,0BAAc;QACd,gCAAiB;QACjB,8BAAgB;QAChB,6BAAe;QACf,+BAAgB;QAChB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAY,CAAC,QAAQ;YACpC,IAAI,EAAE,iBAAU;YAChB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,IAAc;iBAC9B,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const compressPdfAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
optimizeProfile: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compressPdfAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.compressPdfAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.pdf4meAuth,
|
|
10
|
+
name: 'compress_pdf',
|
|
11
|
+
displayName: 'Compress PDF',
|
|
12
|
+
description: 'Reduces the file size of a PDF document while maintaining readability.',
|
|
13
|
+
props: {
|
|
14
|
+
file: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'PDF File',
|
|
16
|
+
description: 'The PDF file to compress.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
optimizeProfile: pieces_framework_1.Property.StaticDropdown({
|
|
20
|
+
displayName: 'Compression Profile',
|
|
21
|
+
description: 'Controls the trade-off between file size and output quality.',
|
|
22
|
+
required: false,
|
|
23
|
+
defaultValue: 'Default',
|
|
24
|
+
options: {
|
|
25
|
+
options: [
|
|
26
|
+
{ label: 'Default (balanced quality and size)', value: 'Default' },
|
|
27
|
+
{ label: 'Web (optimised for online viewing)', value: 'Web' },
|
|
28
|
+
{ label: 'Web Max (aggressive web optimisation)', value: 'WebMax' },
|
|
29
|
+
{ label: 'Print (optimised for printing)', value: 'Print' },
|
|
30
|
+
{ label: 'Print Max (aggressive print optimisation)', value: 'PrintMax' },
|
|
31
|
+
{ label: 'Print Gray (grayscale for print)', value: 'PrintGray' },
|
|
32
|
+
{ label: 'Compress (strong compression)', value: 'Compress' },
|
|
33
|
+
{ label: 'Compress Max (maximum compression)', value: 'CompressMax' },
|
|
34
|
+
{ label: 'Max (maximum size reduction)', value: 'Max' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
run(context) {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const { file, optimizeProfile } = context.propsValue;
|
|
42
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
43
|
+
apiKey: context.auth,
|
|
44
|
+
endpoint: '/api/v2/Optimize',
|
|
45
|
+
body: {
|
|
46
|
+
docContent: file.data.toString('base64'),
|
|
47
|
+
docName: file.filename,
|
|
48
|
+
optimizeProfile: optimizeProfile !== null && optimizeProfile !== void 0 ? optimizeProfile : 'Default',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, file.filename);
|
|
52
|
+
return {
|
|
53
|
+
file_name: fileName,
|
|
54
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
55
|
+
success: true,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=compress-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/compress-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC;AACrC,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WAAW,CAAC;gBAC9C,MAAM,EAAE,OAAO,CAAC,IAAc;gBAC9B,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE;oBACJ,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBACxC,OAAO,EAAE,IAAI,CAAC,QAAQ;oBACtB,eAAe,EAAE,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,SAAS;iBAC9C;aACF,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,qBAAY,CAAC,mBAAmB,CAC/C,QAAQ,CAAC,OAAO,EAChB,IAAI,CAAC,QAAQ,CACd,CAAC;YAEF,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const convertToPdfAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
filename: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToPdfAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.convertToPdfAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.pdf4meAuth,
|
|
10
|
+
name: 'convert_to_pdf',
|
|
11
|
+
displayName: 'Convert File to PDF',
|
|
12
|
+
description: 'Converts a Word, Excel, PowerPoint, or image file to PDF format.',
|
|
13
|
+
props: {
|
|
14
|
+
file: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'File',
|
|
16
|
+
description: 'The file to convert. Supported formats: DOCX, DOC, XLSX, XLS, PPTX, PPT, PNG, JPG, JPEG, GIF, BMP, TIFF.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
filename: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Output Filename',
|
|
21
|
+
description: 'Name for the resulting PDF file (without the .pdf extension). Defaults to the original filename.',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const { file, filename } = context.propsValue;
|
|
28
|
+
const outputName = filename !== null && filename !== void 0 ? filename : file.filename.replace(/\.[^.]+$/, '');
|
|
29
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
30
|
+
apiKey: context.auth,
|
|
31
|
+
endpoint: '/api/v2/ConvertToPdf',
|
|
32
|
+
body: {
|
|
33
|
+
docContent: file.data.toString('base64'),
|
|
34
|
+
docName: file.filename,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, `${outputName}.pdf`);
|
|
38
|
+
return {
|
|
39
|
+
file_name: fileName,
|
|
40
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
41
|
+
success: true,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=convert-to-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-to-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/convert-to-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;A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D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const mergePdfsAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file1: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
file2: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
4
|
+
filename: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergePdfsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.mergePdfsAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.pdf4meAuth,
|
|
10
|
+
name: 'merge_pdfs',
|
|
11
|
+
displayName: 'Merge PDF Files',
|
|
12
|
+
description: 'Combines two or more PDF files into a single PDF document.',
|
|
13
|
+
props: {
|
|
14
|
+
file1: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'First PDF File',
|
|
16
|
+
description: 'The first PDF file to merge. It will appear first in the merged result.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
file2: pieces_framework_1.Property.File({
|
|
20
|
+
displayName: 'Second PDF File',
|
|
21
|
+
description: 'The second PDF file to merge.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
filename: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'Output Filename',
|
|
26
|
+
description: 'Name for the merged PDF file (without the .pdf extension).',
|
|
27
|
+
required: false,
|
|
28
|
+
defaultValue: 'merged',
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
run(context) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { file1, file2, filename } = context.propsValue;
|
|
34
|
+
const outputName = filename !== null && filename !== void 0 ? filename : 'merged';
|
|
35
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
36
|
+
apiKey: context.auth,
|
|
37
|
+
endpoint: '/api/v2/Merge',
|
|
38
|
+
body: {
|
|
39
|
+
docContent: [
|
|
40
|
+
file1.data.toString('base64'),
|
|
41
|
+
file2.data.toString('base64'),
|
|
42
|
+
],
|
|
43
|
+
docName: `${outputName}.pdf`,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, `${outputName}.pdf`);
|
|
47
|
+
return {
|
|
48
|
+
file_name: fileName,
|
|
49
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
50
|
+
success: true,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=merge-pdfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-pdfs.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/merge-pdfs.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC;AACrC,sCAAyC;AAE5B,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACnB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EACT,yEAAyE;YAC3E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACnB,WA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file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
pageNrs: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
imageFormat: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
5
|
+
widthPixel: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdfToImageAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.pdfToImageAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.pdf4meAuth,
|
|
10
|
+
name: 'pdf_to_image',
|
|
11
|
+
displayName: 'Convert PDF to Image',
|
|
12
|
+
description: 'Converts one or more pages of a PDF file to an image.',
|
|
13
|
+
props: {
|
|
14
|
+
file: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'PDF File',
|
|
16
|
+
description: 'The PDF file to convert to an image.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
pageNrs: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Page Numbers',
|
|
21
|
+
description: 'Pages to convert. Examples: "1" (first page only), "1,3,5" (specific pages), "2-5" (range), "all" (every page). Defaults to the first page.',
|
|
22
|
+
required: false,
|
|
23
|
+
defaultValue: '1',
|
|
24
|
+
}),
|
|
25
|
+
imageFormat: pieces_framework_1.Property.StaticDropdown({
|
|
26
|
+
displayName: 'Image Format',
|
|
27
|
+
description: 'The output image format.',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 'PNG',
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{ label: 'PNG (lossless, recommended)', value: 'PNG' },
|
|
33
|
+
{ label: 'JPEG (smaller file size)', value: 'JPG' },
|
|
34
|
+
{ label: 'TIFF', value: 'TIF' },
|
|
35
|
+
{ label: 'BMP', value: 'BMP' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
widthPixel: pieces_framework_1.Property.Number({
|
|
40
|
+
displayName: 'Width (pixels)',
|
|
41
|
+
description: 'Output image width in pixels. Height is calculated automatically to maintain the page aspect ratio.',
|
|
42
|
+
required: false,
|
|
43
|
+
defaultValue: 1920,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
run(context) {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const { file, pageNrs, imageFormat, widthPixel } = context.propsValue;
|
|
49
|
+
const pageSelection = pageNrs !== null && pageNrs !== void 0 ? pageNrs : '1';
|
|
50
|
+
const format = imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'PNG';
|
|
51
|
+
const ext = format.toLowerCase();
|
|
52
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
53
|
+
apiKey: context.auth,
|
|
54
|
+
endpoint: '/api/v2/CreateImages',
|
|
55
|
+
body: {
|
|
56
|
+
docContent: file.data.toString('base64'),
|
|
57
|
+
docname: file.filename,
|
|
58
|
+
imageAction: {
|
|
59
|
+
WidthPixel: widthPixel !== null && widthPixel !== void 0 ? widthPixel : 1920,
|
|
60
|
+
ImageExtension: format,
|
|
61
|
+
},
|
|
62
|
+
pageNrs: pageSelection,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const baseName = file.filename.replace(/\.pdf$/i, '');
|
|
66
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, `${baseName}.${ext}`);
|
|
67
|
+
return {
|
|
68
|
+
file_name: fileName,
|
|
69
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
70
|
+
image_format: ext,
|
|
71
|
+
page_selection: pageSelection,
|
|
72
|
+
success: true,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=pdf-to-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-to-image.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/pdf-to-image.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC;AACrC,sCAAyC;AAE5B,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,uDAAuD;IACpE,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,6IAA6I;YAC/I,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,GAAG;SAClB,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACnC,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,6BAA6B,EAAE,KAAK,EAAE,KAAK,EAAE;oBACtD,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,KAAK,EAAE;oBACnD,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC/B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;iBAC/B;aACF;SACF,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC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AG;gBACjB,cAAc,EAAE,aAAa;gBAC7B,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const pdfToWordAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
qualityType: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
4
|
+
language: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
5
|
+
mergeAllSheets: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
ocrWhenNeeded: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdfToWordAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const LANGUAGE_OPTIONS = [
|
|
9
|
+
{ label: 'English', value: 'English' },
|
|
10
|
+
{ label: 'French', value: 'French' },
|
|
11
|
+
{ label: 'German', value: 'German' },
|
|
12
|
+
{ label: 'Spanish', value: 'Spanish' },
|
|
13
|
+
{ label: 'Italian', value: 'Italian' },
|
|
14
|
+
{ label: 'Portuguese', value: 'Portuguese' },
|
|
15
|
+
{ label: 'Dutch', value: 'Dutch' },
|
|
16
|
+
{ label: 'Russian', value: 'Russian' },
|
|
17
|
+
{ label: 'Chinese', value: 'Chinese' },
|
|
18
|
+
{ label: 'Japanese', value: 'Japanese' },
|
|
19
|
+
{ label: 'Korean', value: 'Korean' },
|
|
20
|
+
{ label: 'Arabic', value: 'Arabic' },
|
|
21
|
+
{ label: 'Hindi', value: 'Hindi' },
|
|
22
|
+
{ label: 'Turkish', value: 'Turkish' },
|
|
23
|
+
{ label: 'Polish', value: 'Polish' },
|
|
24
|
+
{ label: 'Swedish', value: 'Swedish' },
|
|
25
|
+
{ label: 'Danish', value: 'Danish' },
|
|
26
|
+
{ label: 'Norwegian', value: 'Norwegian' },
|
|
27
|
+
{ label: 'Finnish', value: 'Finnish' },
|
|
28
|
+
{ label: 'Czech', value: 'Czech' },
|
|
29
|
+
];
|
|
30
|
+
exports.pdfToWordAction = (0, pieces_framework_1.createAction)({
|
|
31
|
+
auth: auth_1.pdf4meAuth,
|
|
32
|
+
name: 'pdf_to_word',
|
|
33
|
+
displayName: 'Convert PDF to Word',
|
|
34
|
+
description: 'Converts a PDF file to an editable Microsoft Word (DOCX) document.',
|
|
35
|
+
props: {
|
|
36
|
+
file: pieces_framework_1.Property.File({
|
|
37
|
+
displayName: 'PDF File',
|
|
38
|
+
description: 'The PDF file to convert to Word format.',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
qualityType: pieces_framework_1.Property.StaticDropdown({
|
|
42
|
+
displayName: 'Conversion Quality',
|
|
43
|
+
description: 'Draft processes the entire file in one API call. High uses per-page processing — best for scanned or image-heavy PDFs.',
|
|
44
|
+
required: false,
|
|
45
|
+
defaultValue: 'Draft',
|
|
46
|
+
options: {
|
|
47
|
+
options: [
|
|
48
|
+
{ label: 'Draft (faster, one call per file)', value: 'Draft' },
|
|
49
|
+
{ label: 'High (slower, better for scanned PDFs)', value: 'High' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
language: pieces_framework_1.Property.StaticDropdown({
|
|
54
|
+
displayName: 'Document Language',
|
|
55
|
+
description: 'Language of the text in the PDF. Used to improve OCR accuracy.',
|
|
56
|
+
required: false,
|
|
57
|
+
defaultValue: 'English',
|
|
58
|
+
options: { options: LANGUAGE_OPTIONS },
|
|
59
|
+
}),
|
|
60
|
+
mergeAllSheets: pieces_framework_1.Property.Checkbox({
|
|
61
|
+
displayName: 'Merge All Sheets',
|
|
62
|
+
description: 'Merge all pages into a single Word document sheet.',
|
|
63
|
+
required: false,
|
|
64
|
+
defaultValue: false,
|
|
65
|
+
}),
|
|
66
|
+
ocrWhenNeeded: pieces_framework_1.Property.Checkbox({
|
|
67
|
+
displayName: 'Enable OCR for Scanned PDFs',
|
|
68
|
+
description: 'Automatically apply OCR when the PDF contains scanned images instead of selectable text.',
|
|
69
|
+
required: false,
|
|
70
|
+
defaultValue: false,
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
run(context) {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const { file, qualityType, language, mergeAllSheets, ocrWhenNeeded } = context.propsValue;
|
|
76
|
+
const outputName = file.filename.replace(/\.pdf$/i, '');
|
|
77
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
78
|
+
apiKey: context.auth,
|
|
79
|
+
endpoint: '/api/v2/ConvertPdfToWord',
|
|
80
|
+
body: {
|
|
81
|
+
docContent: file.data.toString('base64'),
|
|
82
|
+
docName: file.filename,
|
|
83
|
+
qualityType: qualityType !== null && qualityType !== void 0 ? qualityType : 'Draft',
|
|
84
|
+
language: language !== null && language !== void 0 ? language : 'English',
|
|
85
|
+
mergeAllSheets: mergeAllSheets !== null && mergeAllSheets !== void 0 ? mergeAllSheets : false,
|
|
86
|
+
outputFormat: 'docx',
|
|
87
|
+
ocrWhenNeeded: String(ocrWhenNeeded !== null && ocrWhenNeeded !== void 0 ? ocrWhenNeeded : false),
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, `${outputName}.docx`);
|
|
91
|
+
return {
|
|
92
|
+
file_name: fileName,
|
|
93
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
94
|
+
success: true,
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=pdf-to-word.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-to-word.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/pdf-to-word.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC;AACrC,sCAAyC;AAEzC,MAAM,gBAAgB,GAAG;IACvB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK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C,QAAQ,CAAC;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const protectPdfAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
password: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
pdfPermission: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protectPdfAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.protectPdfAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.pdf4meAuth,
|
|
10
|
+
name: 'protect_pdf',
|
|
11
|
+
displayName: 'Protect PDF with Password',
|
|
12
|
+
description: 'Adds password protection to a PDF file so only authorised users can open it.',
|
|
13
|
+
props: {
|
|
14
|
+
file: pieces_framework_1.Property.File({
|
|
15
|
+
displayName: 'PDF File',
|
|
16
|
+
description: 'The PDF file to protect with a password.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
password: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Password',
|
|
21
|
+
description: 'The password users will need to open the protected PDF.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
pdfPermission: pieces_framework_1.Property.StaticDropdown({
|
|
25
|
+
displayName: 'PDF Permissions',
|
|
26
|
+
description: 'Permissions granted to users who open the protected PDF.',
|
|
27
|
+
required: false,
|
|
28
|
+
defaultValue: 'All',
|
|
29
|
+
options: {
|
|
30
|
+
options: [
|
|
31
|
+
{ label: 'All (no restrictions)', value: 'All' },
|
|
32
|
+
{ label: 'None (no permissions)', value: 'None' },
|
|
33
|
+
{ label: 'Copy', value: 'Copy' },
|
|
34
|
+
{ label: 'Annotate', value: 'Annotate' },
|
|
35
|
+
{ label: 'Fill Forms', value: 'Fill Forms' },
|
|
36
|
+
{ label: 'Support Disabilities', value: 'Support Disabilities' },
|
|
37
|
+
{ label: 'Assemble', value: 'Assemble' },
|
|
38
|
+
{ label: 'Digital Print', value: 'Digital Print' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
run(context) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const { file, password, pdfPermission } = context.propsValue;
|
|
46
|
+
const response = yield common_1.pdf4meCommon.callFileApi({
|
|
47
|
+
apiKey: context.auth,
|
|
48
|
+
endpoint: '/api/v2/Protect',
|
|
49
|
+
body: {
|
|
50
|
+
docContent: file.data.toString('base64'),
|
|
51
|
+
docName: file.filename,
|
|
52
|
+
password,
|
|
53
|
+
pdfPermission: pdfPermission !== null && pdfPermission !== void 0 ? pdfPermission : 'All',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const fileName = common_1.pdf4meCommon.fileNameFromHeaders(response.headers, file.filename);
|
|
57
|
+
return {
|
|
58
|
+
file_name: fileName,
|
|
59
|
+
file_data_base64: Buffer.from(response.body).toString('base64'),
|
|
60
|
+
success: true,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=protect-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protect-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/protect-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC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,GAAG,OAAO,CAAC,UAAU,CAAC;YAE7D,MAAM,QAAQ,GAAG,MAAM,qBAAY,CAAC,WAAW,CAAC;gBAC9C,MAAM,EAAE,OAAO,CAAC,IAAc;gBAC9B,QAAQ,EAAE,iBAAiB;gBAC3B,IAAI,EAAE;oBACJ,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBACxC,OAAO,EAAE,IAAI,CAAC,QAAQ;oBACtB,QAAQ;oBACR,aAAa,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,KAAK;iBACtC;aACF,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,qBAAY,CAAC,mBAAmB,CAC/C,QAAQ,CAAC,OAAO,EAChB,IAAI,CAAC,QAAQ,CACd,CAAC;YAEF,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const splitPdfAction: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
file: import("@taskmagic/pieces-framework").FileProperty<true>;
|
|
3
|
+
splitAction: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, true>;
|
|
4
|
+
splitSettings: import("@taskmagic/pieces-framework").DynamicProperties<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitPdfAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const SPLIT_ACTION_OPTIONS = [
|
|
9
|
+
{
|
|
10
|
+
label: 'Split After Page — split into two parts at a given page',
|
|
11
|
+
value: 'SplitAfterPage',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: 'Recurring Split — split into equal chunks every N pages',
|
|
15
|
+
value: 'RecurringSplitAfterPage',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Split Sequence — split by a sequence of page counts',
|
|
19
|
+
value: 'SplitSequence',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Split Ranges — split using custom page ranges',
|
|
23
|
+
value: 'SplitRanges',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const SPLIT_ACTION_NUMBER_DESCRIPTIONS = {
|
|
27
|
+
SplitAfterPage: 'Page number after which the PDF is split. E.g. 3 → produces pages 1–3 and the rest.',
|
|
28
|
+
RecurringSplitAfterPage: 'Number of pages per chunk. E.g. 5 → splits into parts of 5 pages each.',
|
|
29
|
+
SplitSequence: 'Number of pages in the first sequence chunk.',
|
|
30
|
+
SplitRanges: 'Starting page number of the custom range.',
|
|
31
|
+
};
|
|
32
|
+
exports.splitPdfAction = (0, pieces_framework_1.createAction)({
|
|
33
|
+
auth: auth_1.pdf4meAuth,
|
|
34
|
+
name: 'split_pdf',
|
|
35
|
+
displayName: 'Split PDF',
|
|
36
|
+
description: 'Splits a PDF file into multiple documents using one of four split strategies.',
|
|
37
|
+
props: {
|
|
38
|
+
file: pieces_framework_1.Property.File({
|
|
39
|
+
displayName: 'PDF File',
|
|
40
|
+
description: 'The PDF file to split.',
|
|
41
|
+
required: true,
|
|
42
|
+
}),
|
|
43
|
+
splitAction: pieces_framework_1.Property.StaticDropdown({
|
|
44
|
+
displayName: 'Split Strategy',
|
|
45
|
+
description: 'How the PDF should be split.',
|
|
46
|
+
required: true,
|
|
47
|
+
defaultValue: 'SplitAfterPage',
|
|
48
|
+
options: { options: SPLIT_ACTION_OPTIONS },
|
|
49
|
+
}),
|
|
50
|
+
splitSettings: pieces_framework_1.Property.DynamicProperties({
|
|
51
|
+
displayName: 'Split Settings',
|
|
52
|
+
refreshers: ['splitAction'],
|
|
53
|
+
required: true,
|
|
54
|
+
props: (propsValue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const action = String((_a = propsValue['splitAction']) !== null && _a !== void 0 ? _a : 'SplitAfterPage');
|
|
57
|
+
const description = (_b = SPLIT_ACTION_NUMBER_DESCRIPTIONS[action]) !== null && _b !== void 0 ? _b : 'Number controlling the split behaviour for the chosen strategy.';
|
|
58
|
+
return {
|
|
59
|
+
splitActionNumber: pieces_framework_1.Property.Number({
|
|
60
|
+
displayName: 'Split Number',
|
|
61
|
+
description,
|
|
62
|
+
required: true,
|
|
63
|
+
defaultValue: 1,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
run(context) {
|
|
70
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
72
|
+
const { file, splitAction, splitSettings } = context.propsValue;
|
|
73
|
+
const splitActionNumber = splitSettings === null || splitSettings === void 0 ? void 0 : splitSettings['splitActionNumber'];
|
|
74
|
+
const response = yield common_1.pdf4meCommon.callJsonApi({
|
|
75
|
+
apiKey: context.auth,
|
|
76
|
+
endpoint: '/api/v2/SplitPDF',
|
|
77
|
+
body: {
|
|
78
|
+
docContent: file.data.toString('base64'),
|
|
79
|
+
docName: file.filename,
|
|
80
|
+
splitAction: splitAction !== null && splitAction !== void 0 ? splitAction : 'SplitAfterPage',
|
|
81
|
+
splitActionNumber: splitActionNumber !== null && splitActionNumber !== void 0 ? splitActionNumber : 1,
|
|
82
|
+
fileNaming: 'NameAsPerOrder',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
const docs = (_a = response.body['splited Documents']) !== null && _a !== void 0 ? _a : [];
|
|
86
|
+
return {
|
|
87
|
+
parts_count: docs.length,
|
|
88
|
+
part_1_file_name: (_e = (_c = (_b = docs[0]) === null || _b === void 0 ? void 0 : _b['docName']) !== null && _c !== void 0 ? _c : (_d = docs[0]) === null || _d === void 0 ? void 0 : _d['name']) !== null && _e !== void 0 ? _e : null,
|
|
89
|
+
part_1_file_data_base64: (_j = (_g = (_f = docs[0]) === null || _f === void 0 ? void 0 : _f['docContent']) !== null && _g !== void 0 ? _g : (_h = docs[0]) === null || _h === void 0 ? void 0 : _h['docData']) !== null && _j !== void 0 ? _j : null,
|
|
90
|
+
part_2_file_name: (_o = (_l = (_k = docs[1]) === null || _k === void 0 ? void 0 : _k['docName']) !== null && _l !== void 0 ? _l : (_m = docs[1]) === null || _m === void 0 ? void 0 : _m['name']) !== null && _o !== void 0 ? _o : null,
|
|
91
|
+
part_2_file_data_base64: (_s = (_q = (_p = docs[1]) === null || _p === void 0 ? void 0 : _p['docContent']) !== null && _q !== void 0 ? _q : (_r = docs[1]) === null || _r === void 0 ? void 0 : _r['docData']) !== null && _s !== void 0 ? _s : null,
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=split-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/actions/split-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,kCAAqC;AACrC,sCAAyC;AAKzC,MAAM,oBAAoB,GAAG;IAC3B;QACE,KAAK,EAAE,yDAAyD;QAChE,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,yDAAyD;QAChE,KAAK,EAAE,yBAAyB;KACjC;IACD;QACE,KAAK,EAAE,qDAAqD;QAC5D,KAAK,EA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CAAC,mCAAI,MAAA,IAAI,CAAC,CAAC,CAAC,0CAAG,MAAM,CAAC,mCAAI,IAAI;gBACnE,uBAAuB,EACrB,MAAA,MAAA,MAAA,IAAI,CAAC,CAAC,CAAC,0CAAG,YAAY,CAAC,mCAAI,MAAA,IAAI,CAAC,CAAC,CAAC,0CAAG,SAAS,CAAC,mCAAI,IAAI;aAC1D,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pdf4meAuth: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdf4meAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
5
|
+
exports.pdf4meAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
6
|
+
displayName: 'API Key',
|
|
7
|
+
description: `To get your PDF4me API key:
|
|
8
|
+
1. Go to your [API Keys dashboard](https://dev.pdf4me.com/dashboard/#/api-keys/)
|
|
9
|
+
2. Sign in or create a free account if you don't have one
|
|
10
|
+
3. Copy your API key and paste it here`,
|
|
11
|
+
required: true,
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/community/pdf4me/src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,kEAAwD;AAE3C,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE;;;uCAGwB;IACrC,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpMessageBody, HttpResponse } from '@taskmagic/pieces-common';
|
|
2
|
+
declare function callFileApi({ apiKey, endpoint, body, }: {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
body: Record<string, unknown>;
|
|
6
|
+
}): Promise<HttpResponse<ArrayBuffer>>;
|
|
7
|
+
declare function callJsonApi<T extends HttpMessageBody>({ apiKey, endpoint, body, }: {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
body: Record<string, unknown>;
|
|
11
|
+
}): Promise<HttpResponse<T>>;
|
|
12
|
+
declare function fileNameFromHeaders(headers: Record<string, string | string[] | undefined> | undefined, fallback: string): string;
|
|
13
|
+
export declare const pdf4meCommon: {
|
|
14
|
+
BASE_URL: string;
|
|
15
|
+
callFileApi: typeof callFileApi;
|
|
16
|
+
callJsonApi: typeof callJsonApi;
|
|
17
|
+
fileNameFromHeaders: typeof fileNameFromHeaders;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pdf4meCommon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const BASE_URL = 'https://api.pdf4me.com';
|
|
7
|
+
function callFileApi(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, endpoint, body, }) {
|
|
9
|
+
return pieces_common_1.httpClient.sendRequest({
|
|
10
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
11
|
+
url: `${BASE_URL}${endpoint}`,
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: apiKey,
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
body,
|
|
17
|
+
responseType: 'arraybuffer',
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function callJsonApi(_a) {
|
|
22
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, endpoint, body, }) {
|
|
23
|
+
return pieces_common_1.httpClient.sendRequest({
|
|
24
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
25
|
+
url: `${BASE_URL}${endpoint}`,
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: apiKey,
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
},
|
|
30
|
+
body,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function fileNameFromHeaders(headers, fallback) {
|
|
35
|
+
var _a;
|
|
36
|
+
const raw = (_a = headers === null || headers === void 0 ? void 0 : headers['content-disposition']) !== null && _a !== void 0 ? _a : headers === null || headers === void 0 ? void 0 : headers['Content-Disposition'];
|
|
37
|
+
const cd = Array.isArray(raw) ? raw[0] : (raw !== null && raw !== void 0 ? raw : '');
|
|
38
|
+
const match = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(cd);
|
|
39
|
+
if (!match)
|
|
40
|
+
return fallback;
|
|
41
|
+
return match[1].replace(/['"]/g, '').trim() || fallback;
|
|
42
|
+
}
|
|
43
|
+
exports.pdf4meCommon = {
|
|
44
|
+
BASE_URL,
|
|
45
|
+
callFileApi,
|
|
46
|
+
callJsonApi,
|
|
47
|
+
fileNameFromHeaders,
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf4me/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,4DAKkC;AAElC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAE1C,SAAe,WAAW;iEAAC,EACzB,MAAM,EACN,QAAQ,EACR,IAAI,GAKL;QACC,OAAO,0BAAU,CAAC,WAAW,CAAc;YACzC,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,GAAG,QAAQ,GAAG,QAAQ,EA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