Skip to content

Commit 161748b

Browse files
authored
New Components - pdf_app_net (#14406)
* new components * pnpm-lock.yaml * fix summary
1 parent 505a6d2 commit 161748b

File tree

6 files changed

+218
-59
lines changed

6 files changed

+218
-59
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pdfApp from "../../pdf_app_net.app.mjs";
2+
3+
export default {
4+
key: "pdf_app_net-compress-pdf",
5+
name: "Compress PDF",
6+
description: "Compress a PDF File with PDF-app.net. [See the documentation](https://pdf-app.net/apidocumentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
pdfApp,
11+
fileUrl: {
12+
type: "string",
13+
label: "File URL",
14+
description: "The URL of a .pdf file to compress",
15+
},
16+
fileName: {
17+
propDefinition: [
18+
pdfApp,
19+
"fileName",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.pdfApp.compressPdf({
25+
$,
26+
data: {
27+
fileUrl: this.fileUrl,
28+
async: false,
29+
fileName: this.fileName,
30+
},
31+
});
32+
$.export("$summary", "Successfully compressed PDF File");
33+
return response;
34+
},
35+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pdfApp from "../../pdf_app_net.app.mjs";
2+
3+
export default {
4+
key: "pdf_app_net-image-to-pdf",
5+
name: "Image to PDF",
6+
description: "Convert an image from a URL to a PDF File with PDF-app.net. [See the documentation](https://pdf-app.net/apidocumentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
pdfApp,
11+
imageUrl: {
12+
type: "string",
13+
label: "Image URL",
14+
description: "The URL of an image file to convert",
15+
},
16+
fileName: {
17+
propDefinition: [
18+
pdfApp,
19+
"fileName",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.pdfApp.imageToPdf({
25+
$,
26+
data: {
27+
imageUrls: [
28+
this.imageUrl,
29+
],
30+
async: false,
31+
fileName: this.fileName,
32+
},
33+
});
34+
$.export("$summary", "Successfully converted image to PDF File");
35+
return response;
36+
},
37+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pdfApp from "../../pdf_app_net.app.mjs";
2+
3+
export default {
4+
key: "pdf_app_net-split-pdf",
5+
name: "Split PDF",
6+
description: "Split a PDF into multiple PDFs containing the specified number of pages. [See the documentation](https://pdf-app.net/apidocumentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
pdfApp,
11+
fileUrl: {
12+
type: "string",
13+
label: "File URL",
14+
description: "The URL of a .pdf file to split",
15+
},
16+
pagesPerSplit: {
17+
type: "integer",
18+
label: "Pages",
19+
description: "Each PDF will contain the specified number of pages. For instance, if the original PDF contains 6 pages, and `Pages` is `2`, the result will be 3 files, each containing 2 pages.",
20+
},
21+
fileName: {
22+
propDefinition: [
23+
pdfApp,
24+
"fileName",
25+
],
26+
},
27+
},
28+
async run({ $ }) {
29+
const response = await this.pdfApp.splitPdf({
30+
$,
31+
data: {
32+
fileUrl: this.fileUrl,
33+
pagesPerSplit: this.pagesPerSplit,
34+
async: false,
35+
fileName: this.fileName,
36+
},
37+
});
38+
$.export("$summary", "Successfully split PDF File");
39+
return response;
40+
},
41+
};

components/pdf_app_net/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pdf_app_net",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream PDF-app.net Components",
55
"main": "pdf_app_net.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "pdf_app_net",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
fileName: {
8+
type: "string",
9+
label: "File Name",
10+
description: "The name of the file",
11+
optional: true,
12+
},
13+
},
514
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
15+
_baseUrl() {
16+
return "https://api.pdf-app.net";
17+
},
18+
_makeRequest({
19+
$ = this,
20+
path,
21+
...opts
22+
}) {
23+
return axios($, {
24+
method: "POST",
25+
url: `${this._baseUrl()}${path}`,
26+
headers: {
27+
"Authorization": `${this.$auth.api_key}`,
28+
},
29+
...opts,
30+
});
31+
},
32+
compressPdf(opts = {}) {
33+
return this._makeRequest({
34+
path: "/compress_PDF",
35+
...opts,
36+
});
37+
},
38+
imageToPdf(opts = {}) {
39+
return this._makeRequest({
40+
path: "/image_to_pdf",
41+
...opts,
42+
});
43+
},
44+
splitPdf(opts = {}) {
45+
return this._makeRequest({
46+
path: "/splitt_PDF",
47+
...opts,
48+
});
949
},
1050
},
11-
};
51+
};

pnpm-lock.yaml

Lines changed: 55 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)