-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - html_to_image #14655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
components/html_to_image/actions/convert-html-to-image/convert-html-to-image.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
71 changes: 71 additions & 0 deletions
71
components/html_to_image/actions/convert-html-to-pdf/convert-html-to-pdf.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; | ||
64 changes: 64 additions & 0 deletions
64
components/html_to_image/actions/convert-url-to-image/convert-url-to-image.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ], | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
64 changes: 64 additions & 0 deletions
64
components/html_to_image/actions/convert-url-to-pdf/convert-url-to-pdf.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ], | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| }); | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| convertToImage(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/generateImage", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| convertToPdf(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/generatePdf", | ||
| ...opts, | ||
| }); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.