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

Not generating when PDF is more than one page #124

Open
sulthan-ahmed opened this issue Mar 1, 2019 · 0 comments
Open

Not generating when PDF is more than one page #124

sulthan-ahmed opened this issue Mar 1, 2019 · 0 comments

Comments

@sulthan-ahmed
Copy link

sulthan-ahmed commented Mar 1, 2019

I'm passing in a html page that will create multiple pages. WKHTML doesn't seem to have a problem when the pdf generated is one page. However, when it is goes beyond that, the app just hangs. Here is my code

generate: (html, destination, tempName) => {
    return new Promise((resolve, reject) => {
      const file = `${destination}/${tempName}`;
      const readStream = fs.createReadStream(html);
      wkhtmltopdf(readStream, (err, stream) => {
        if (err) {
          console.log(`Pdf generation: Failed, something went wrong
            reading the template ${html}, further details here -> ${err}`);
          reject(err);
        } else {
          // on finish ensures that fs is finished writing the file
          stream.pipe(fs.createWriteStream(file)).on('finish',
            () => resolve(file));
          console.log('pdf generated at', file);
        }
      });
    });
  }

Here is a link to the code
https://github.com/UKHomeOffice/modern-slavery/blob/MS-812-PDF-design-v2/apps/pdf/util/pdf-generator.js
Here is the link to the html I am passing
https://github.com/UKHomeOffice/modern-slavery/blob/MS-812-PDF-design-v2/apps/pdf/views/pdf.html

I'd be grateful for your help, thanks in advance

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

1 participant