Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import htmlToImage from "../../html_to_image.app.mjs";

export default {
key: "html_to_image-convert-html-to-image",
name: "Convert HTML to Image",
description: "Create an image from HTML. [See the documentation](https://docs.htmlcsstoimg.com/html-to-image-api/html-css-to-image-api).",
version: "0.0.1",
type: "action",
props: {
htmlToImage,
htmlContent: {
propDefinition: [
htmlToImage,
"htmlContent",
],
},
cssContent: {
propDefinition: [
htmlToImage,
"cssContent",
],
},
font: {
type: "string",
label: "Font",
description: "Google Font Name that needs to be imported when generating image from HTML & CSS. To pass multiple fonts, separate them with | sign. Example - `Roboto|Georgia`",
optional: true,
},
quality: {
propDefinition: [
htmlToImage,
"quality",
],
},
},
async run({ $ }) {
const response = await this.htmlToImage.convertToImage({
$,
data: {
html_content: this.htmlContent,
css_content: this.cssContent,
font: this.font,
quality: this.quality,
generate_img_url: true,
},
});
$.export("$summary", "Successfully converted HTML to image");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import htmlToImage from "../../html_to_image.app.mjs";

export default {
key: "html_to_image-convert-html-to-pdf",
name: "Convert HTML to PDF",
description: "Create a PDF file from HTML. [See the documentation](https://docs.htmlcsstoimg.com/html-to-image-api/html-css-to-pdf-api).",
version: "0.0.1",
type: "action",
props: {
htmlToImage,
htmlContent: {
propDefinition: [
htmlToImage,
"htmlContent",
],
},
cssContent: {
propDefinition: [
htmlToImage,
"cssContent",
],
},
paperSize: {
propDefinition: [
htmlToImage,
"paperSize",
],
},
landscape: {
propDefinition: [
htmlToImage,
"landscape",
],
},
displayHeaderFooter: {
propDefinition: [
htmlToImage,
"displayHeaderFooter",
],
},
printBackground: {
propDefinition: [
htmlToImage,
"printBackground",
],
},
preferCssPageSize: {
type: "boolean",
label: "Prefer CSS Page Size",
description: "Get size from CSS styles. Default: `true`",
optional: true,
},
},
async run({ $ }) {
const response = await this.htmlToImage.convertToPdf({
$,
data: {
html_content: this.htmlContent,
css_content: this.cssContent,
paper_size: this.paperSize,
landscape: this.landscape,
displayHeaderFooter: this.displayHeaderFooter,
printBackground: this.printBackground,
preferCssPageSize: this.preferCssPageSize,
generate_pdf_url: true,
},
});
$.export("$summary", "Successfully converted HTML to PDF");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import htmlToImage from "../../html_to_image.app.mjs";

export default {
key: "html_to_image-convert-url-to-image",
name: "Convert URL to Image",
description: "Capture a screenshot from a URL. [See the documentation](https://docs.htmlcsstoimg.com/html-to-image-api/screenshot-capture-api).",
version: "0.0.1",
type: "action",
props: {
htmlToImage,
url: {
propDefinition: [
htmlToImage,
"url",
],
},
viewPortWidth: {
type: "integer",
label: "View Port Width",
description: "Width of View Port. Default value is 1080",
optional: true,
},
viewPortHeight: {
type: "integer",
label: "View Port Height",
description: "Height of View Port. Default value is 720",
optional: true,
},
quality: {
propDefinition: [
htmlToImage,
"quality",
],
},
fullPage: {
type: "boolean",
label: "Full Page",
description: "Whether to capture full-page screenshot of the URL. Default value is `false`.",
optional: true,
},
waitUntil: {
propDefinition: [
htmlToImage,
"waitUntil",
],
},
},
async run({ $ }) {
const response = await this.htmlToImage.convertToImage({
$,
data: {
url: this.url,
viewPortWidth: this.viewPortWidth,
viewPortHeight: this.viewPortHeight,
quality: this.quality,
full_page: this.fullPage,
wait_till: this.waitUntil,
generate_img_url: true,
},
});
$.export("$summary", "Successfully converted URL to image");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import htmlToImage from "../../html_to_image.app.mjs";

export default {
key: "html_to_image-convert-url-to-pdf",
name: "Convert URL to PDF",
description: "Create a PDF from a URL. [See the documentation](https://docs.htmlcsstoimg.com/html-to-image-api/url-to-pdf-api).",
version: "0.0.1",
type: "action",
props: {
htmlToImage,
url: {
propDefinition: [
htmlToImage,
"url",
],
},
paperSize: {
propDefinition: [
htmlToImage,
"paperSize",
],
},
landscape: {
propDefinition: [
htmlToImage,
"landscape",
],
},
displayHeaderFooter: {
propDefinition: [
htmlToImage,
"displayHeaderFooter",
],
},
printBackground: {
propDefinition: [
htmlToImage,
"printBackground",
],
},
waitUntil: {
propDefinition: [
htmlToImage,
"waitUntil",
],
},
},
async run({ $ }) {
const response = await this.htmlToImage.convertToPdf({
$,
data: {
url: this.url,
paper_size: this.paperSize,
landscape: this.landscape,
displayHeaderFooter: this.displayHeaderFooter,
printBackground: this.printBackground,
wait_till: this.waitUntil,
generate_pdf_url: true,
},
});
$.export("$summary", "Successfully converted URL to PDF");
return response;
},
};
96 changes: 92 additions & 4 deletions components/html_to_image/html_to_image.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,99 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "html_to_image",
propDefinitions: {},
propDefinitions: {
url: {
type: "string",
label: "URL",
description: "The URL of the webpage",
},
htmlContent: {
type: "string",
label: "HTML Content",
description: "HTML Content to be used",
},
cssContent: {
type: "string",
label: "CSS Content",
description: "CSS Content to be used",
optional: true,
},
quality: {
type: "integer",
label: "Quality",
description: "Quality of the image should be in the range 30-100. Default value is 30.",
optional: true,
},
paperSize: {
type: "string",
label: "Paper Size",
description: "Size of the paper",
options: [
"A3",
"A4",
"A5",
"Letter",
"Legal",
],
optional: true,
},
landscape: {
type: "boolean",
label: "Landscape",
description: "Page orientation where the content is formatted horizontally. By default the page orientation is Portrait",
optional: true,
},
displayHeaderFooter: {
type: "boolean",
label: "Display Header Footer",
description: "Generated PDF with have header and Footer on each page",
optional: true,
},
printBackground: {
type: "boolean",
label: "Print Background",
description: "Prints any background colors or images used on the web page to the PDF. Its default value is `true`.",
optional: true,
},
waitUntil: {
type: "integer",
label: "Wait Until",
description: " Number of seconds to wait before capturing a screenshot from the URL. Default value is 0",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.htmlcsstoimg.com/api/v1";
},
_makeRequest({
$ = this,
path,
...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
"CLIENT-API-KEY": this.$auth.api_key,
},
...opts,
});
},
convertToImage(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/generateImage",
...opts,
});
},
convertToPdf(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/generatePdf",
...opts,
});
},
},
};
7 changes: 5 additions & 2 deletions components/html_to_image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/html_to_image",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream HTML to Image Components",
"main": "html_to_image.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
Loading
Loading