Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diogoangelim/html-screenshots
Take screenshots from server side rendered html.
https://github.com/diogoangelim/html-screenshots
Last synced: 5 days ago
JSON representation
Take screenshots from server side rendered html.
- Host: GitHub
- URL: https://github.com/diogoangelim/html-screenshots
- Owner: DiogoAngelim
- License: mit
- Created: 2024-08-24T15:20:48.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-02T19:57:49.000Z (5 months ago)
- Last Synced: 2024-11-13T02:36:08.923Z (2 months ago)
- Language: JavaScript
- Size: 8.66 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# HTML Screenshots
This module generates a preview image from HTML content using Puppeteer. It allows the injection of custom CSS and JavaScript files, saves the generated image as a JPEG, and returns a base64 string representation of the image.
## InstallationInstall HTML Screenshots with npm:
```bash
npm install html-screenshots
```
## Usage/Examples```javascript
import icon from 'html-screenshots';const basePath: '/path/to/save/image',
const htmlContent = `
Hello, World!
This is a test.
`;const options = {
cssFiles: ['styles.css'],
jsFiles: ['script.js']
};(async () => {
try {
await icon(basePath, htmlContent, options);
} catch (error) {
console.error('Error generating image:', error.message);
}
})();```