Git Product home page Git Product logo

jsreport-wkhtmltopdf's Introduction

⚠️ This repository has been moved to the monorepo jsreport/jsreport

jsreport-wkhtmltopdf

NPM Version License Build Status

jsreport recipe for rendering pdf using wkhtmltopdf

Installation

npm install jsreport-wkhtmltopdf

Usage

To use recipe in for template rendering set template.recipe=phantom-wkhtmltopdf in the rendering request.

{
  template: { content: '...', recipe: 'wkhtmltopdf', enginne: '...', wkhtmltopdf: { ... } }
}

See the docs https://jsreport.net/learn/wkhtmltopdf

jsreport-core

You can apply this extension also manually to jsreport-core

var jsreport = require('jsreport-core')()
jsreport.use(require('jsreport-wkhtmltopdf')())

jsreport-wkhtmltopdf's People

Contributors

bjrmatos avatar mi53re avatar pofider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsreport-wkhtmltopdf's Issues

Sporatic Issue Generating PDFs

So I am having an issue generating PDFs from handlebars templates. This is being used on AWS and sometimes in very large volume. Recently I started getting the following error trace and cannot figure out what the true error is. I personally cannot reproduce the error, but it has begun to happen daily. Here is the trace:

ERROR: Error during rendering report: Command failed: /var/task/node_modules/wkhtmltopdf-installer/vendor/wkhtmltopdf --debug-javascript --page-size Letter --margin-bottom 15mm --margin-left 5mm --margin-right 5mm --margin-top 29mm --orientation Portrait --header-spacing 3 --header-html file:////tmp/jsreport-temp/617e1b90-f4d7-11e7-8021-af53ee976040header.html --footer-spacing 3 --footer-html file:////tmp/jsreport-temp/617e1b90-f4d7-11e7-8021-af53ee976040footer.html /tmp/jsreport-temp/617e1b90-f4d7-11e7-8021-af53ee976040.html /tmp/jsreport-temp/617e1b90-f4d7-11e7-8021-af53ee976040.pdf

Here are the fatal level log messages received:

Error
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[===========================> ] 45%
[============================> ] 48%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
[> ] 1%
[=> ] 2%
[=> ] 3%
[===> ] 5%
[===> ] 6%
[====> ] 7%
[====> ] 8%
[======> ] 10%
[=========> ] 15%
[============> ] 21%
[===============> ] 26%
[===================> ] 32%
[======================> ] 37%
[=========================> ] 43%
[============================> ] 48%
[=================================> ] 55%
[====================================> ] 60%
[=======================================> ] 66%
[==========================================> ] 71%
[==============================================> ] 77%
[=================================================> ] 82%
[====================================================> ] 88%
[=======================================================> ] 93%
[============================================================] 100%
Printing pages (6/6)
[> ] Preparing
[===============> ] Page 1 of 4
[==============================> ] Page 2 of 4
[=============================================> ] Page 3 of 4
[============================================================] Page 4 of 4
[============================================================] Page 5 of 4

Stack Trace:
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[===========================> ] 45%
[============================> ] 48%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
[> ] 1%
[=> ] 2%
[=> ] 3%
[===> ] 5%
[===> ] 6%
[====> ] 7%
[====> ] 8%
[======> ] 10%
[=========> ] 15%
[============> ] 21%
[===============> ] 26%
[===================> ] 32%
[======================> ] 37%
[=========================> ] 43%
[============================> ] 48%
[=================================> ] 55%
[====================================> ] 60%
[=======================================> ] 66%
[==========================================> ] 71%
[==============================================> ] 77%
[=================================================> ] 82%
[====================================================> ] 88%
[=======================================================> ] 93%
[============================================================] 100%
Printing pages (6/6)
[> ] Preparing
[===============> ] Page 1 of 4
[==============================> ] Page 2 of 4
[=============================================> ] Page 3 of 4
[============================================================] Page 4 of 4
[============================================================] Page 5 of 4
ChildProcess.exithandler (child_process.js:204:12)
emitTwo (events.js:106:13)
ChildProcess.emit (events.js:191:7)
maybeClose (internal/child_process.js:886:16)
Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

The only thing I notice is that on the Printing step, the last thing it says in Page 5 of 4, and I have no idea why it would do that.

Thanks in advance to anyone who can help shed some light on this.

Issue with accessing local files

Hi, I am creating a pf from html string and I am having an image in html which I also want in pdf along with the other content.I am using nodejs for this.

So when i try to create the pdf of the created html string, it gives the following error log:

Error during rendering report: Command failed: D:\nodeJs learning\sails js learning\FirstSailsApp\node_modules\jsreport-wkhtmltopdf\node_modules\wkhtmltopdf-installer\vendor\wkhtmltopdf.exe --disable-local-file-access C:\Users\DCS\AppData\Local\Temp\jsreport-temp\e1400c60-02eb-11e6-ac5f-9166e442552a.html C:\Users\DCS\AppData\Local\Temp\jsreport-temp\e1400c60-02eb-11e6-ac5f-9166e442552a.pdf
Loading pages (1/6)
[> ] 0%
[======> ] 10%
Warning: Blocked access to file
[========================> ] 40%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[============================================================] Page 1 of 1
Done
Exit with code 1 due to network error: ProtocolUnknownError

Also I have set the wkhtmltopdf's, allowLoaclFilesAccess to true, but yet it starts wkhtmltopdf.exe with --disable-local-file-access command.

What should i do to fix this.

downloaded wkhtmltopdf not working on OSX

when you try to execute the wkhtmltopdf on OSX you get the following error: cannot execute binary file

captura de pantalla 2017-03-28 a las 5 17 19 p m

after some search on google this seems to be a problem on the wkhtmltopdf file itself, seems that the downloaded version is unable to work on OSX.

wkhtmltopdf-installer wkhtmltopdf.exe` binary doesn't seem to work correctly issue

I have this in my package.json file:

{
"name": "pdf",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"jsreport-core": "^1.3.1",
"jsreport-phantom-pdf": "^1.4.4",
"jsreport-jsrender": "^1.0.2",
"jsreport-wkhtmltopdf": "^1.4.0",
"jsreport-handlebars": "^1.1.2"
},
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC"
}

When I run npm install , I am getting this error

[email protected] postinstall C:\app\node_modules\wkhtmltopdf-installer
node lib/install.js

‼ Global command wkhtmltopdf doesn't seem to work. Downloading wkhtmltopdf localy to /vendor ...
× Error: The C:\app\node_modules\wkhtmltopdf-installer\vendor\wkhtmltopdf.exe binary doesn't seem to work correctly
at BinWrapper. (C:\app\node_modules\bin-wrapper\index.js:156:7)
at ChildProcess. (C:\app\node_modules\bin-check\index.js:26:4)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
Try running vendor/wkhtmltopdf to get more detailed error output.
npm notice created a lockfile as package-lock.json. You should commit this file.

Node version 8.9.0
I am running it with microsoft/aspnetcore:2.0-nanoserver-sac2016 docker image as base with node installed.

Return generated file name

Hi,

pls can you make small modification, that will return auto-generated file name? Because it is impossible to delete generated files, because names are automatically generated and hash is not returned.

  • ex: wkhtmltopdf.js
    response.export = {
        fileName: 'f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce'
    }; 

      response.headers["Content-Type"] = "application/pdf";
      response.headers["Content-Disposition"] = "inline; filename=\"report.pdf\"";
      response.headers["File-Extension"] = "pdf";
  • than, i can in node.js remove created pdf and html in temp folders:
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce.pdf
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ce.html
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16cefooter.html
f9dbc8a0-c50f-11e5-8c4c-23b94b1c16ceheader.html

Thank you

Make --disable-local-file-access optional

Hi, i want to use local server images, but in your definition, you put there param params.push("--disable-local-file-access");.

Can you make it as option ?

Thank you

function createParams (request, options, id) {
  var params = [];

  params.push("--disable-local-file-access");

  if (options.pageHeight) {
    params.push("--page-height");
    params.push(options.pageHeight);
  }
..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.