marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 543 forks source link

just generating the first page #534

Closed YDoro closed 5 years ago

YDoro commented 5 years ago

html-pdf is just generating the first page, i'm trying to generate a dynamic pdf from a request and it just generates the first page and the header of the second page; some example:

=========================================================================== const express = require("express"); const fs = require("fs"); const router = express.Router(); const path = require("path"); const pdf = require("html-pdf"); const caminho_t_alvara = path.join(

router.post("/generate", async (req, res) => { var options = { format: "A4" }; const { data, code, name} = req.body; var fileoutput = path.join(__dirname, ../Outputs/${code}${name}.pdf);

pdf .create( `<!DOCTYPE html>

Alvará

${data}

`, options ) .toFile(fileoutput, function(err, res) { if (err) return console.log(err); }); var stat = null; setTimeout(() => { stat = fs.statSync(fileoutput); res.writeHead(200, { "Content-Type": "application/pdf", "Content-Length": stat.size }); fs.createReadStream(fileoutput).pipe(res); }, 5000); fs.unlink(fileoutput); }); module.exports = app => app.use("/pdf", router); =========================================================================== if the request data is greater then one page it will print only the first page and the header of a second page if the header is configured, if isn't the second page will be a blank page ....
elite-developer1055 commented 4 years ago

Hey, did you resolve this issue? @YDoro