hajareshyam / pdf-creator-node

This package is used to generate HTML to PDF in Nodejs
MIT License
238 stars 79 forks source link

Any example how to save just html code to pdf, not using template file? #74

Open lofti198 opened 2 years ago

lofti198 commented 2 years ago

Hi! Any example how to save just html code to pdf, not using template file?

lofti198 commented 2 years ago

Guess Ive found the answer var pdf = require("pdf-creator-node");

// Read HTML Template var html = <h1>test</h1>

var options = { format: "A3", orientation: "portrait", border: "10mm", };

var document = { html: html, data: { }, path: "./output.pdf", type: "", // "stream" || "buffer" || "" ("" defaults to pdf) };

console.log(document); pdf .create(document, options) .then((res) => { console.log(res); }) .catch((error) => { console.error(error); });

lofti198 commented 2 years ago

now how can I put images into output pdf file? I mean in what format they must exist into the input html? Just like tag? <img... ?

XXXL3J commented 1 year ago

Insert img tag with base64 data, instead of file address