Skip to content
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

Feature request: Add url option to nodeHtmlToImage #220

Open
sachinchillal opened this issue Jan 20, 2024 · 1 comment
Open

Feature request: Add url option to nodeHtmlToImage #220

sachinchillal opened this issue Jan 20, 2024 · 1 comment

Comments

@sachinchillal
Copy link

Feature request: Add url option to nodeHtmlToImage

Description

I would like to be able to pass an HTML page link instead of HTML text to the nodeHtmlToImage function, so that I can render the page as an image without having to read the HTML content first.

Example

For example, I want to do something like this:

const nodeHtmlToImage = require('node-html-to-image')

nodeHtmlToImage({
  output: './image.png',
  url: 'http://localhost:3000/black-card.html?index=1&cardPos=bottom&imgPos=bottom' // the link to the HTML page I want to convert to image
})
.then(() => console.log('The image was created successfully!'))

url can be

Use case

This feature would be useful for me because I have a web app that generates dynamic HTML pages based on some parameters, and I want to save them as images for later use. It would be more convenient and efficient to pass the page link directly to the nodeHtmlToImage function, rather than reading the HTML content and passing it as a string.

Alternatives

I have not found any alternatives that can achieve the same functionality as nodeHtmlToImage, but with the url option. If you know any, please let me know.

Additional context

I am using node-html-to-image version 3.3.0 and Node.js version 16.16.0 on Windows 11.

Thank you for your consideration and your great work on this library!

@shanerich
Copy link

You can use the Puppeteer or Playwright libraries directly to achieve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants