Skip to content

Commit a022458

Browse files
PDF Munk components
1 parent 31e4b0a commit a022458

File tree

6 files changed

+376
-6
lines changed

6 files changed

+376
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import app from "../../pdf_munk.app.mjs";
2+
3+
export default {
4+
key: "pdf_munk-capture-website-screenshot-into-image",
5+
name: "Capture Website Screenshot into Image",
6+
description: "Capture Screenshot of a Website URL into an image. [See documentation](https://pdfmunk.com/api-docs#:~:text=Image%20Generation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
url: {
12+
type: "string",
13+
label: "Website URL",
14+
description: "The URL of the website to capture as a screenshot",
15+
},
16+
},
17+
async run({ $ }) {
18+
const { url } = this;
19+
20+
const response = await this.app.captureWebsiteScreenshot({
21+
$,
22+
url,
23+
});
24+
25+
$.export("$summary", `Successfully captured screenshot of ${url}`);
26+
return response;
27+
},
28+
};
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import app from "../../pdf_munk.app.mjs";
2+
3+
export default {
4+
key: "pdf_munk-capture-website-screenshot-into-pdf",
5+
name: "Capture Website Screenshot into PDF",
6+
description: "Converts a URL to a PDF file with customizable options. [See documentation](https://pdfmunk.com/api-docs#:~:text=Operations%20related%20to%20PDF)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
url: {
12+
type: "string",
13+
label: "Website URL",
14+
description: "The URL of the website to convert to PDF",
15+
},
16+
paper_size: {
17+
type: "string",
18+
label: "Paper Size",
19+
description: "The paper size for the PDF",
20+
options: [
21+
{
22+
label: "A4",
23+
value: "A4",
24+
},
25+
{
26+
label: "A3",
27+
value: "A3",
28+
},
29+
{
30+
label: "A5",
31+
value: "A5",
32+
},
33+
{
34+
label: "Letter",
35+
value: "Letter",
36+
},
37+
{
38+
label: "Legal",
39+
value: "Legal",
40+
},
41+
{
42+
label: "Tabloid",
43+
value: "Tabloid",
44+
},
45+
],
46+
default: "A4",
47+
},
48+
landscape: {
49+
type: "boolean",
50+
label: "Landscape",
51+
description: "Whether to use landscape orientation",
52+
default: false,
53+
},
54+
displayHeaderFooter: {
55+
type: "boolean",
56+
label: "Display Header Footer",
57+
description: "Whether to display header and footer",
58+
default: false,
59+
},
60+
page_size: {
61+
type: "integer",
62+
label: "Page Size",
63+
description: "The page size in points",
64+
default: 5,
65+
},
66+
printBackground: {
67+
type: "boolean",
68+
label: "Print Background",
69+
description: "Whether to print background graphics",
70+
default: true,
71+
},
72+
},
73+
async run({ $ }) {
74+
const {
75+
url,
76+
paper_size,
77+
landscape,
78+
displayHeaderFooter,
79+
page_size,
80+
printBackground,
81+
} = this;
82+
83+
const response = await this.app.captureWebsiteToPdf({
84+
$,
85+
url,
86+
paper_size,
87+
landscape,
88+
displayHeaderFooter,
89+
page_size,
90+
printBackground,
91+
});
92+
93+
$.export("$summary", `Successfully converted ${url} to PDF`);
94+
return response;
95+
},
96+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import app from "../../pdf_munk.app.mjs";
2+
3+
export default {
4+
key: "pdf_munk-convert-html-to-image",
5+
name: "Convert HTML to Image",
6+
description: "Converts HTML/CSS content to an image. [See documentation](https://pdfmunk.com/api-docs#:~:text=Image%20Generation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
html_content: {
12+
type: "string",
13+
label: "HTML Content",
14+
description: "The HTML content to convert to an image",
15+
},
16+
css_content: {
17+
type: "string",
18+
label: "CSS Content",
19+
description: "The CSS content to style the HTML",
20+
optional: true,
21+
},
22+
width: {
23+
type: "integer",
24+
label: "Width",
25+
description: "The width of the generated image in pixels",
26+
default: 800,
27+
},
28+
height: {
29+
type: "integer",
30+
label: "Height",
31+
description: "The height of the generated image in pixels",
32+
default: 600,
33+
},
34+
},
35+
async run({ $ }) {
36+
const {
37+
html_content,
38+
css_content,
39+
width,
40+
height,
41+
} = this;
42+
43+
const response = await this.app.convertHtmlToImage({
44+
$,
45+
html_content,
46+
css_content,
47+
width,
48+
height,
49+
});
50+
51+
$.export("$summary", "Successfully converted HTML to image");
52+
return response;
53+
},
54+
};
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import app from "../../pdf_munk.app.mjs";
2+
3+
export default {
4+
key: "pdf_munk-convert-html-to-pdf",
5+
name: "Convert HTML to PDF",
6+
description: "Converts HTML/CSS content to a PDF file with customizable options. [See documentation](https://pdfmunk.com/api-docs#:~:text=Operations%20related%20to%20PDF)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
html_content: {
12+
type: "string",
13+
label: "HTML Content",
14+
description: "The HTML content to convert to PDF",
15+
},
16+
css_content: {
17+
type: "string",
18+
label: "CSS Content",
19+
description: "The CSS content to style the HTML",
20+
optional: true,
21+
},
22+
paper_size: {
23+
type: "string",
24+
label: "Paper Size",
25+
description: "The paper size for the PDF",
26+
options: [
27+
{
28+
label: "A4",
29+
value: "A4",
30+
},
31+
{
32+
label: "A3",
33+
value: "A3",
34+
},
35+
{
36+
label: "A5",
37+
value: "A5",
38+
},
39+
{
40+
label: "Letter",
41+
value: "Letter",
42+
},
43+
{
44+
label: "Legal",
45+
value: "Legal",
46+
},
47+
{
48+
label: "Tabloid",
49+
value: "Tabloid",
50+
},
51+
],
52+
default: "A4",
53+
},
54+
page_size: {
55+
type: "integer",
56+
label: "Page Size",
57+
description: "The page size in points",
58+
default: 2,
59+
},
60+
},
61+
async run({ $ }) {
62+
const {
63+
html_content,
64+
css_content,
65+
paper_size,
66+
page_size,
67+
} = this;
68+
69+
const response = await this.app.convertHtmlToPdf({
70+
$,
71+
html_content,
72+
css_content,
73+
paper_size,
74+
page_size,
75+
});
76+
77+
$.export("$summary", "Successfully converted HTML to PDF");
78+
return response;
79+
},
80+
};

components/pdf_munk/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_munk",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream PDF Munk Components",
55
"main": "pdf_munk.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.1.0"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)