@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.
Files changed (41) hide show
  1. package/README.md +7 -0
  2. package/package.json +47 -0
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +28 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/add-barcode-to-pdf.d.ts +15 -0
  7. package/src/lib/actions/add-barcode-to-pdf.js +148 -0
  8. package/src/lib/actions/add-barcode-to-pdf.js.map +1 -0
  9. package/src/lib/actions/add-image-to-pdf.d.ts +14 -0
  10. package/src/lib/actions/add-image-to-pdf.js +114 -0
  11. package/src/lib/actions/add-image-to-pdf.js.map +1 -0
  12. package/src/lib/actions/add-text-to-pdf.d.ts +21 -0
  13. package/src/lib/actions/add-text-to-pdf.js +149 -0
  14. package/src/lib/actions/add-text-to-pdf.js.map +1 -0
  15. package/src/lib/actions/convert-html-to-pdf.d.ts +14 -0
  16. package/src/lib/actions/convert-html-to-pdf.js +190 -0
  17. package/src/lib/actions/convert-html-to-pdf.js.map +1 -0
  18. package/src/lib/actions/convert-pdf-to-structured-format.d.ts +12 -0
  19. package/src/lib/actions/convert-pdf-to-structured-format.js +123 -0
  20. package/src/lib/actions/convert-pdf-to-structured-format.js.map +1 -0
  21. package/src/lib/actions/extract-tables-from-pdf.d.ts +11 -0
  22. package/src/lib/actions/extract-tables-from-pdf.js +103 -0
  23. package/src/lib/actions/extract-tables-from-pdf.js.map +1 -0
  24. package/src/lib/actions/extract-text-from-pdf.d.ts +8 -0
  25. package/src/lib/actions/extract-text-from-pdf.js +96 -0
  26. package/src/lib/actions/extract-text-from-pdf.js.map +1 -0
  27. package/src/lib/actions/index.d.ts +8 -0
  28. package/src/lib/actions/index.js +12 -0
  29. package/src/lib/actions/index.js.map +1 -0
  30. package/src/lib/actions/search-and-replace-text.d.ts +13 -0
  31. package/src/lib/actions/search-and-replace-text.js +99 -0
  32. package/src/lib/actions/search-and-replace-text.js.map +1 -0
  33. package/src/lib/auth.d.ts +1 -0
  34. package/src/lib/auth.js +10 -0
  35. package/src/lib/auth.js.map +1 -0
  36. package/src/lib/common/props.d.ts +8 -0
  37. package/src/lib/common/props.js +33 -0
  38. package/src/lib/common/props.js.map +1 -0
  39. package/src/lib/common/types.d.ts +37 -0
  40. package/src/lib/common/types.js +3 -0
  41. package/src/lib/common/types.js.map +1 -0
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertHtmlToPdf = 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.convertHtmlToPdf = (0, pieces_framework_1.createAction)({
10
+ name: 'convert_html_to_pdf',
11
+ displayName: 'Convert HTML to PDF',
12
+ description: 'Convert HTML code into a downloadable PDF document.',
13
+ auth: auth_1.pdfCoAuth,
14
+ props: {
15
+ html: pieces_framework_1.Property.LongText({
16
+ displayName: 'HTML Content',
17
+ description: 'The HTML code to convert to PDF.',
18
+ required: true,
19
+ }),
20
+ name: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Output File Name',
22
+ description: 'Desired name for the output PDF file (e.g., "result.pdf").',
23
+ required: false,
24
+ }),
25
+ margins: pieces_framework_1.Property.ShortText({
26
+ displayName: 'Margins',
27
+ description: 'CSS style margins (e.g., "10px", "5mm 5mm 5mm 5mm" for top, right, bottom, left).',
28
+ required: false,
29
+ }),
30
+ paperSize: pieces_framework_1.Property.StaticDropdown({
31
+ displayName: 'Paper Size',
32
+ description: "Select a paper size. For custom sizes, input the value directly (e.g., '200mm 300mm') if your desired size isn't listed. Refer to PDF.co docs.",
33
+ required: false,
34
+ options: {
35
+ disabled: false,
36
+ placeholder: 'Select paper size or input custom',
37
+ options: [
38
+ { label: 'A4 (Default)', value: 'A4' },
39
+ { label: 'Letter', value: 'Letter' },
40
+ { label: 'Legal', value: 'Legal' },
41
+ { label: 'Tabloid', value: 'Tabloid' },
42
+ { label: 'Ledger', value: 'Ledger' },
43
+ { label: 'A0', value: 'A0' },
44
+ { label: 'A1', value: 'A1' },
45
+ { label: 'A2', value: 'A2' },
46
+ { label: 'A3', value: 'A3' },
47
+ { label: 'A5', value: 'A5' },
48
+ { label: 'A6', value: 'A6' },
49
+ ],
50
+ },
51
+ }),
52
+ orientation: pieces_framework_1.Property.StaticDropdown({
53
+ displayName: 'Orientation',
54
+ description: 'Set page orientation.',
55
+ required: false,
56
+ options: {
57
+ disabled: false,
58
+ placeholder: 'Portrait (Default)',
59
+ options: [
60
+ { label: 'Portrait (Default)', value: 'Portrait' },
61
+ { label: 'Landscape', value: 'Landscape' },
62
+ ],
63
+ },
64
+ }),
65
+ printBackground: pieces_framework_1.Property.Checkbox({
66
+ displayName: 'Print Background ?',
67
+ description: 'Set to true to print background graphics and colors (default is true).',
68
+ required: false,
69
+ defaultValue: true,
70
+ }),
71
+ mediaType: pieces_framework_1.Property.StaticDropdown({
72
+ displayName: 'Media Type',
73
+ description: 'CSS media type to emulate.',
74
+ required: false,
75
+ options: {
76
+ disabled: false,
77
+ placeholder: 'print (Default)',
78
+ options: [
79
+ { label: 'print (Default)', value: 'print' },
80
+ { label: 'screen', value: 'screen' },
81
+ { label: 'none', value: 'none' },
82
+ ],
83
+ },
84
+ }),
85
+ header: pieces_framework_1.Property.LongText({
86
+ displayName: 'Header HTML',
87
+ description: 'HTML content for the page header.',
88
+ required: false,
89
+ }),
90
+ footer: pieces_framework_1.Property.LongText({
91
+ displayName: 'Footer HTML',
92
+ description: 'HTML content for the page footer.',
93
+ required: false,
94
+ }),
95
+ doNotWaitFullLoad: pieces_framework_1.Property.Checkbox({
96
+ displayName: 'Do not wait till full page load ?',
97
+ required: false,
98
+ }),
99
+ expiration: pieces_framework_1.Property.Number({
100
+ displayName: 'Output Link Expiration (minutes)',
101
+ description: 'Set the expiration time for the output link in minutes (default is 60).',
102
+ required: false,
103
+ }),
104
+ profiles: pieces_framework_1.Property.Json({
105
+ displayName: 'Profiles',
106
+ description: 'JSON object for additional configurations.',
107
+ required: false,
108
+ }),
109
+ },
110
+ run(context) {
111
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
112
+ var _a;
113
+ const { auth, propsValue } = context;
114
+ const requestBody = {
115
+ html: propsValue.html,
116
+ async: false,
117
+ DoNotWaitFullLoad: propsValue.doNotWaitFullLoad,
118
+ };
119
+ if (propsValue.name !== undefined && propsValue.name !== '')
120
+ requestBody.name = propsValue.name;
121
+ if (propsValue.margins !== undefined && propsValue.margins !== '')
122
+ requestBody.margins = propsValue.margins;
123
+ if (propsValue.paperSize !== undefined)
124
+ requestBody.paperSize = propsValue.paperSize;
125
+ if (propsValue.orientation !== undefined)
126
+ requestBody.orientation = propsValue.orientation;
127
+ if (propsValue.printBackground !== undefined)
128
+ requestBody.printBackground = propsValue.printBackground;
129
+ if (propsValue.mediaType !== undefined)
130
+ requestBody.mediaType = propsValue.mediaType;
131
+ if (propsValue.header !== undefined && propsValue.header !== '')
132
+ requestBody.header = propsValue.header;
133
+ if (propsValue.footer !== undefined && propsValue.footer !== '')
134
+ requestBody.footer = propsValue.footer;
135
+ if (propsValue.expiration !== undefined)
136
+ requestBody.expiration = propsValue.expiration;
137
+ if (propsValue.profiles !== undefined &&
138
+ typeof propsValue.profiles === 'object' &&
139
+ propsValue.profiles !== null) {
140
+ requestBody.profiles = propsValue.profiles;
141
+ }
142
+ try {
143
+ const response = yield pieces_common_1.httpClient.sendRequest({
144
+ method: pieces_common_1.HttpMethod.POST,
145
+ url: `${props_1.BASE_URL}/pdf/convert/from/html`,
146
+ headers: {
147
+ 'x-api-key': auth,
148
+ 'Content-Type': 'application/json',
149
+ },
150
+ body: requestBody,
151
+ });
152
+ if (response.body.error) {
153
+ const errorBody = response.body;
154
+ let errorMessage = `PDF.co API Error (Convert HTML to PDF): Status ${errorBody.status}.`;
155
+ if (errorBody.message) {
156
+ errorMessage += ` Message: ${errorBody.message}.`;
157
+ }
158
+ else {
159
+ errorMessage += ` An unspecified error occurred.`;
160
+ }
161
+ errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
162
+ throw new Error(errorMessage);
163
+ }
164
+ const successBody = response.body;
165
+ return {
166
+ outputUrl: successBody.url,
167
+ pageCount: successBody.pageCount,
168
+ outputName: successBody.name,
169
+ creditsUsed: successBody.credits,
170
+ remainingCredits: successBody.remainingCredits,
171
+ };
172
+ }
173
+ catch (error) {
174
+ if (error instanceof pieces_common_1.HttpError) {
175
+ const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
176
+ let detailedMessage = `HTTP Error calling PDF.co API (Convert HTML to PDF): ${error.message}.`;
177
+ if (responseBody && responseBody.message) {
178
+ detailedMessage += ` Server message: ${responseBody.message}.`;
179
+ }
180
+ else if (responseBody) {
181
+ detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
182
+ }
183
+ throw new Error(detailedMessage);
184
+ }
185
+ throw error;
186
+ }
187
+ });
188
+ },
189
+ });
190
+ //# sourceMappingURL=convert-html-to-pdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-html-to-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/convert-html-to-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAA6E;AAE7E,kCAAoC;AACpC,2CAA2C;AAkB9B,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,gBAAS;IACf,KAAK,EAAE;QACN,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,I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AAM,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,wDAAwD,KAAK,CAAC,OAAO,GAAG,CAAC;oBAC/F,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,12 @@
1
+ export declare const convertPdfToStructuredFormat: 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
+ outputFormat: import("@taskmagic/pieces-framework").StaticDropdownProperty<"json" | "csv" | "xml", true>;
9
+ pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
10
+ lang: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
11
+ profiles: import("@taskmagic/pieces-framework").JsonProperty<false>;
12
+ }>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPdfToStructuredFormat = 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.convertPdfToStructuredFormat = (0, pieces_framework_1.createAction)({
10
+ name: 'convert_pdf_to_structured_format',
11
+ displayName: 'Convert PDF to JSON/CSV/XML',
12
+ description: 'Convert PDF content into structured formats (JSON, CSV, or XML).',
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 convert.',
17
+ required: true,
18
+ }), outputFormat: pieces_framework_1.Property.StaticDropdown({
19
+ displayName: 'Output Format',
20
+ description: 'Select the desired structured output format.',
21
+ required: true,
22
+ options: {
23
+ disabled: false,
24
+ options: [
25
+ { label: 'JSON', value: 'json' },
26
+ { label: 'CSV', value: 'csv' },
27
+ { label: 'XML', value: 'xml' },
28
+ ],
29
+ },
30
+ }), pages: pieces_framework_1.Property.ShortText({
31
+ displayName: 'Pages',
32
+ description: 'Comma-separated page numbers or ranges (e.g., "0,2,5-10"). Leave empty for all pages.',
33
+ required: false,
34
+ }), lang: pieces_framework_1.Property.ShortText({
35
+ displayName: 'OCR Language',
36
+ description: 'Language for OCR if processing scanned documents (e.g., "eng", "deu", "eng+deu"). See PDF.co docs for list.',
37
+ required: false,
38
+ }), profiles: pieces_framework_1.Property.Json({
39
+ displayName: 'Profiles',
40
+ description: 'JSON object for additional configurations.',
41
+ required: false,
42
+ }) }, props_1.commonProps),
43
+ run(context) {
44
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ var _a;
46
+ const { auth, propsValue } = context;
47
+ const { url, outputFormat, pages, lang, pdfPassword, fileName, httpPassword, httpUsername, expiration, profiles, } = propsValue;
48
+ let endpoint = '';
49
+ switch (outputFormat) {
50
+ case 'json':
51
+ endpoint = `${props_1.BASE_URL}/pdf/convert/to/json2`;
52
+ break;
53
+ case 'csv':
54
+ endpoint = `${props_1.BASE_URL}/pdf/convert/to/csv`;
55
+ break;
56
+ case 'xml':
57
+ endpoint = `${props_1.BASE_URL}/pdf/convert/to/xml`;
58
+ break;
59
+ default:
60
+ throw new Error(`Unsupported output format: ${outputFormat}`);
61
+ }
62
+ const requestBody = {
63
+ url: url,
64
+ async: false,
65
+ httppassword: httpPassword,
66
+ httpusername: httpUsername,
67
+ inline: false, // Ensure we get the URL to the output file
68
+ };
69
+ if (pages !== undefined && pages !== '')
70
+ requestBody.pages = pages;
71
+ if (lang !== undefined && lang !== '')
72
+ requestBody.lang = lang;
73
+ if (pdfPassword !== undefined && pdfPassword !== '')
74
+ requestBody.password = pdfPassword;
75
+ if (fileName !== undefined && fileName !== '')
76
+ requestBody.name = fileName;
77
+ if (expiration !== undefined)
78
+ requestBody.expiration = expiration;
79
+ if (profiles !== undefined && typeof profiles === 'object' && profiles !== null) {
80
+ requestBody.profiles = profiles;
81
+ }
82
+ try {
83
+ const response = yield pieces_common_1.httpClient.sendRequest({
84
+ method: pieces_common_1.HttpMethod.POST,
85
+ url: endpoint,
86
+ headers: {
87
+ 'x-api-key': auth,
88
+ 'Content-Type': 'application/json',
89
+ },
90
+ body: requestBody,
91
+ });
92
+ if (response.body.error) {
93
+ const errorBody = response.body;
94
+ let errorMessage = `PDF.co API Error (Convert PDF to ${outputFormat.toUpperCase()}): Status ${errorBody.status}.`;
95
+ if (errorBody.message) {
96
+ errorMessage += ` Message: ${errorBody.message}.`;
97
+ }
98
+ else {
99
+ errorMessage += ` An unspecified error occurred.`;
100
+ }
101
+ errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
102
+ throw new Error(errorMessage);
103
+ }
104
+ return response.body;
105
+ }
106
+ catch (error) {
107
+ if (error instanceof pieces_common_1.HttpError) {
108
+ const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
109
+ let detailedMessage = `HTTP Error calling PDF.co API (Convert PDF to ${outputFormat.toUpperCase()}): ${error.message}.`;
110
+ if (responseBody && responseBody.message) {
111
+ detailedMessage += ` Server message: ${responseBody.message}.`;
112
+ }
113
+ else if (responseBody) {
114
+ detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
115
+ }
116
+ throw new Error(detailedMessage);
117
+ }
118
+ throw error;
119
+ }
120
+ });
121
+ },
122
+ });
123
+ //# sourceMappingURL=convert-pdf-to-structured-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-pdf-to-structured-format.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/convert-pdf-to-structured-format.ts"],"names":[],"mappings":";;;;AAAA,kEAAqF;AACrF,4DAA6E;AAE7E,kCAAoC;AACpC,2CAAwD;AAiB3C,QAAA,4BAA4B,GAAG,IAAA,+BAAY,EAAC;IACxD,IAAI,EAAE,kCAAkC;IACxC,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,kEAAkE;IAC/E,IAAI,EAAE,gBAAS;IACf,KAAK,kBACJ,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,YAAY,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACrC,WAAW,EAAE,eAAe;YAC5B,WAAW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EAAE,CAAC;oBACzB,MAAM,SAAS,GAAG,QAAQ,CAAC,IAA0B,CAAC;oBACtD,IAAI,YAAY,GAAG,oCAAoC,YAAY,CAAC,WAAW,EAAE,aAChF,SAAS,CAAC,MACX,GAAG,CAAC;oBACJ,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;wBACvB,YAAY,IAAI,aAAa,SAAS,CAAC,OAAO,GAAG,CAAC;oBACnD,CAAC;yBAAM,CAAC;wBACP,YAAY,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,OAAO,QAAQ,CAAC,IAAI,CAAC;YACtB,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,iDAAiD,YAAY,CAAC,WAAW,EAAE,MAChG,KAAK,CAAC,OACP,GAAG,CAAC;oBACJ,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,11 @@
1
+ export declare const extractTablesFromPdf: 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
+ templateId: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
9
+ pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
10
+ profiles: import("@taskmagic/pieces-framework").JsonProperty<false>;
11
+ }>;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTablesFromPdf = 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.extractTablesFromPdf = (0, pieces_framework_1.createAction)({
10
+ name: 'extract_tables_from_pdf',
11
+ displayName: 'Extract Tables from PDF (using Template)',
12
+ description: 'Extracts table data from a PDF using a predefined PDF.co Document Parser template.',
13
+ auth: auth_1.pdfCoAuth, // Inherits auth from the piece
14
+ props: Object.assign({ url: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Source PDF URL',
16
+ description: 'URL of the PDF file to extract tables from.',
17
+ required: true,
18
+ }), templateId: pieces_framework_1.Property.ShortText({
19
+ displayName: 'Template ID',
20
+ description: 'The ID of your Document Parser template (created in PDF.co dashboard) designed to extract the table(s).',
21
+ required: true,
22
+ }), pages: pieces_framework_1.Property.ShortText({
23
+ displayName: 'Pages',
24
+ description: 'Comma-separated page numbers or ranges (e.g., "0,2,5-10"). Overrides template settings if provided.',
25
+ required: false,
26
+ }), profiles: pieces_framework_1.Property.Json({
27
+ displayName: 'Profiles',
28
+ description: 'JSON object for additional configurations.',
29
+ required: false,
30
+ }) }, props_1.commonProps),
31
+ run(context) {
32
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
+ var _a;
34
+ const { auth, propsValue } = context;
35
+ const { url, templateId, pages, pdfPassword, fileName, httpPassword, httpUsername, expiration, profiles, } = propsValue;
36
+ const requestBody = {
37
+ url: url,
38
+ templateId: templateId,
39
+ httppassword: httpPassword,
40
+ httpusername: httpUsername,
41
+ async: false,
42
+ inline: true, // Get the parsed data directly
43
+ outputFormat: 'JSON', // We want JSON to process tables
44
+ };
45
+ if (pages !== undefined && pages !== '')
46
+ requestBody.pages = pages;
47
+ if (pdfPassword !== undefined && pdfPassword !== '')
48
+ requestBody.password = pdfPassword;
49
+ if (fileName !== undefined && fileName !== '')
50
+ requestBody.name = fileName;
51
+ if (expiration !== undefined)
52
+ requestBody.expiration = expiration;
53
+ if (profiles !== undefined && typeof profiles === 'object' && profiles !== null) {
54
+ requestBody.profiles = profiles;
55
+ }
56
+ try {
57
+ const response = yield pieces_common_1.httpClient.sendRequest({
58
+ method: pieces_common_1.HttpMethod.POST,
59
+ url: `${props_1.BASE_URL}/pdf/documentparser`,
60
+ headers: {
61
+ 'x-api-key': auth,
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ body: requestBody,
65
+ });
66
+ if (response.body.error) {
67
+ const errorBody = response.body;
68
+ let errorMessage = `PDF.co API Error (Extract Tables): Status ${errorBody.status}.`;
69
+ if (errorBody.message) {
70
+ errorMessage += ` Message: ${errorBody.message}.`;
71
+ }
72
+ else {
73
+ errorMessage += ` An unspecified error occurred.`;
74
+ }
75
+ errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
76
+ throw new Error(errorMessage);
77
+ }
78
+ const successBody = response.body;
79
+ // Filter the results to return only table objects
80
+ const tables = successBody.body.objects.filter((obj) => obj.objectType === 'table');
81
+ return {
82
+ extractedTables: tables, // Array of table objects found by the template
83
+ templateNameUsed: successBody.body.templateName,
84
+ };
85
+ }
86
+ catch (error) {
87
+ if (error instanceof pieces_common_1.HttpError) {
88
+ const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
89
+ let detailedMessage = `HTTP Error calling PDF.co API (Extract Tables): ${error.message}.`;
90
+ if (responseBody && responseBody.message) {
91
+ detailedMessage += ` Server message: ${responseBody.message}.`;
92
+ }
93
+ else if (responseBody) {
94
+ detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
95
+ }
96
+ throw new Error(detailedMessage);
97
+ }
98
+ throw error;
99
+ }
100
+ });
101
+ },
102
+ });
103
+ //# sourceMappingURL=extract-tables-from-pdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-tables-from-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/extract-tables-from-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAA6E;AAE7E,kCAAoC;AACpC,2CAAwD;AA8C3C,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,0CAA0C;IACvD,WAAW,EAAE,oFAAoF;IACjG,IAAI,EAAE,gBAAS,EAAE,+BAA+B;IAChD,KAAK,kBACJ,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,WAAW,EACV,yGAAyG;YAC1G,QAAQ,EAAE,IAAI;SACd,CAAC,EACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,OAAO;YACpB,WAAW,EACV,qGAAqG;YACtG,QAAQ,EAAE,KAAK;SACf,CAAC,EACF,QAAQ,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACvB,WAAW,EAAE,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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,8 @@
1
+ export declare const extractTextFromPdf: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
2
+ url: import("@taskmagic/pieces-framework").ShortTextProperty<true>;
3
+ pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
4
+ password: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
5
+ outputName: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
6
+ httpUsername: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
7
+ httpPassword: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
8
+ }>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTextFromPdf = 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.extractTextFromPdf = (0, pieces_framework_1.createAction)({
10
+ name: 'extract_text_from_pdf',
11
+ displayName: 'Extract Plain Text from PDF',
12
+ description: 'Extracts plain text content from a PDF document.',
13
+ auth: auth_1.pdfCoAuth,
14
+ props: {
15
+ url: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Source PDF URL',
17
+ description: 'URL of the PDF file to extract text from.',
18
+ required: true,
19
+ }),
20
+ pages: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Pages',
22
+ description: 'Comma-separated page numbers or ranges (e.g., "0,2,5-10"). Leave empty for all pages.',
23
+ required: false,
24
+ }),
25
+ password: props_1.commonProps.pdfPassword,
26
+ outputName: props_1.commonProps.fileName,
27
+ httpUsername: props_1.commonProps.httpUsername,
28
+ httpPassword: props_1.commonProps.httpPassword,
29
+ },
30
+ run(context) {
31
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
+ var _a;
33
+ const { auth, propsValue } = context;
34
+ const { url, pages, password, outputName, httpPassword, httpUsername } = propsValue;
35
+ const requestBody = {
36
+ url: url,
37
+ async: false,
38
+ httpusername: httpUsername,
39
+ httppassword: httpPassword,
40
+ inline: true, // Get text directly in response.body.body
41
+ };
42
+ if (pages !== undefined && pages !== '')
43
+ requestBody.pages = pages;
44
+ if (password !== undefined && password !== '')
45
+ requestBody.password = password;
46
+ if (outputName !== undefined && outputName !== '')
47
+ requestBody.name = outputName;
48
+ try {
49
+ const response = yield pieces_common_1.httpClient.sendRequest({
50
+ method: pieces_common_1.HttpMethod.POST,
51
+ url: `${props_1.BASE_URL}/pdf/convert/to/text-simple`,
52
+ headers: {
53
+ 'x-api-key': auth,
54
+ 'Content-Type': 'application/json',
55
+ },
56
+ body: requestBody,
57
+ });
58
+ if (response.body.error) {
59
+ const errorBody = response.body;
60
+ let errorMessage = `PDF.co API Error (Extract Text): Status ${errorBody.status}.`;
61
+ if (errorBody.message) {
62
+ errorMessage += ` Message: ${errorBody.message}.`;
63
+ }
64
+ else {
65
+ errorMessage += ` An unspecified error occurred.`;
66
+ }
67
+ errorMessage += ` Raw response: ${JSON.stringify(errorBody)}`;
68
+ throw new Error(errorMessage);
69
+ }
70
+ const successBody = response.body;
71
+ return {
72
+ extractedText: successBody.body,
73
+ pageCount: successBody.pageCount,
74
+ outputName: successBody.name,
75
+ creditsUsed: successBody.credits,
76
+ remainingCredits: successBody.remainingCredits,
77
+ };
78
+ }
79
+ catch (error) {
80
+ if (error instanceof pieces_common_1.HttpError) {
81
+ const responseBody = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body;
82
+ let detailedMessage = `HTTP Error calling PDF.co API (Extract Text): ${error.message}.`;
83
+ if (responseBody && responseBody.message) {
84
+ detailedMessage += ` Server message: ${responseBody.message}.`;
85
+ }
86
+ else if (responseBody) {
87
+ detailedMessage += ` Server response: ${JSON.stringify(responseBody)}.`;
88
+ }
89
+ throw new Error(detailedMessage);
90
+ }
91
+ throw error;
92
+ }
93
+ });
94
+ },
95
+ });
96
+ //# sourceMappingURL=extract-text-from-pdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-text-from-pdf.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/extract-text-from-pdf.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAA6E;AAC7E,kCAAoC;AACpC,2CAAwD;AAiC3C,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,kDAAkD;IAC/D,IAAI,EAAE,gBAAS;IACf,KAAK,EAAE;QACN,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,OAAO;YACpB,WAAW,EACV,uFAAuF;YACxF,QAAQ,EAAE,KAAK;SACf,CAAC;QACF,QAAQ,EAAE,mBAAW,CAAC,WAAW;QACjC,UAAU,EAAE,mBAAW,CAAC,QAAQ;QAChC,YAAY,EAAE,mBAAW,CAAC,YAAY;QACtC,YAAY,EAAE,mBAAW,CAAC,YAAY;KACtC;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,MAAM,EAAE,GAA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AS,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC9D,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;gBAC/B,CAAC;gBAED,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAuC,CAAC;gBAErE,OAAO;oBACN,aAAa,EAAE,WAAW,CAAC,IAAI;oBAC/B,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,iDAAiD,KAAK,CAAC,OAAO,GAAG,CAAC;oBACxF,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,8 @@
1
+ export * from './search-and-replace-text';
2
+ export * from './add-text-to-pdf';
3
+ export * from './add-image-to-pdf';
4
+ export * from './convert-html-to-pdf';
5
+ export * from './extract-text-from-pdf';
6
+ export * from './convert-pdf-to-structured-format';
7
+ export * from './extract-tables-from-pdf';
8
+ export * from './add-barcode-to-pdf';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./search-and-replace-text"), exports);
5
+ tslib_1.__exportStar(require("./add-text-to-pdf"), exports);
6
+ tslib_1.__exportStar(require("./add-image-to-pdf"), exports);
7
+ tslib_1.__exportStar(require("./convert-html-to-pdf"), exports);
8
+ tslib_1.__exportStar(require("./extract-text-from-pdf"), exports);
9
+ tslib_1.__exportStar(require("./convert-pdf-to-structured-format"), exports);
10
+ tslib_1.__exportStar(require("./extract-tables-from-pdf"), exports);
11
+ tslib_1.__exportStar(require("./add-barcode-to-pdf"), exports);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pdf-co/src/lib/actions/index.ts"],"names":[],"mappings":";;;AAAA,oEAA0C;AAC1C,4DAAkC;AAClC,6DAAmC;AACnC,gEAAsC;AACtC,kEAAwC;AACxC,6EAAmD;AACnD,oEAA0C;AAC1C,+DAAqC"}
@@ -0,0 +1,13 @@
1
+ export declare const searchAndReplaceText: 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
+ searchStrings: import("@taskmagic/pieces-framework").ArrayProperty<true>;
9
+ replaceStrings: import("@taskmagic/pieces-framework").ArrayProperty<true>;
10
+ caseSensitive: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
11
+ regex: import("@taskmagic/pieces-framework").CheckboxProperty<false>;
12
+ pages: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
13
+ }>;