https://github.com/vigzmv/micro-pdf
HTML in PDF out. Node Micro-service to convert HTML into PDFs :page_facing_up:
https://github.com/vigzmv/micro-pdf
microservice pdf pupeteer
Last synced: about 2 months ago
JSON representation
HTML in PDF out. Node Micro-service to convert HTML into PDFs :page_facing_up:
- Host: GitHub
- URL: https://github.com/vigzmv/micro-pdf
- Owner: vigzmv
- License: mit
- Created: 2019-12-08T16:20:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T23:07:35.000Z (about 4 years ago)
- Last Synced: 2025-06-17T08:07:15.596Z (9 months ago)
- Topics: microservice, pdf, pupeteer
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# micro-pdf
Node Micro-service to convert HTML into PDFs :page_facing_up:
Uses [Puppeteer](https://github.com/puppeteer/puppeteer) to render the page with a real chrome headless browser and prints it to PDF. Uses real chrome browser so what you see on your browser is what you get. This makes development much easier.
[](https://heroku.com/deploy?template=https://github.com/vigzmv/micro-pdf)
## Server Side
Can be hosted on any provider with node runtime support.
```sh
npm install
npm run start
```
## Client Side
Make a post request with `{ html : `YOUR_HTML` }` and the response will be the PDF document
### Example:
```js
fetch("http://localhost:3000", {
method: "POST",
body: JSON.stringify({
html: "
Hello I am a PDF
",
}),
})
.then((response) => response.blob())
.then((blob) => {
var url = window.URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = url;
a.download = "example.pdf"; // You can set the name programmatically
document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox
a.click();
a.remove(); //afterwards we remove the element
});
```