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

Produces a blank PDF file via CLI in v7.0.0 #268

Open
kristofmulier opened this issue Apr 14, 2020 · 2 comments
Open

Produces a blank PDF file via CLI in v7.0.0 #268

kristofmulier opened this issue Apr 14, 2020 · 2 comments

Comments

@kristofmulier
Copy link

kristofmulier commented Apr 14, 2020

I'm using electron-pdf in Ubuntu 19.10, installed in the following way:

    $ sudo apt-get upgrade
    $ sudo apt install nodejs
    $ sudo apt install npm
    $ sudo npm install npm@latest -g
    $ sudo npm install electron-pdf -g --unsafe-perm

Now I try to convert an .html document into a .pdf:

$ electron-pdf input.html output.pdf

The result is a blank pdf file.

If I do the same conversion, but with absolute paths, it works:

$ electron-pdf /home/kristof/Documents/invoices/input.html /home/kristof/Documents/invoices/output.pdf

Now I get a nice pdf file, just perfect.

The same issue was already raised long time ago: #173

It seems like it was fixed, but now it emerges again?

@Dattish
Copy link

Dattish commented Apr 28, 2020

This might be Linux specific, I run into the same problem on my Ubuntu (18.04) installation but it works fine on Windows 10.

edit: doing the following to args.js:urlWithArgs solves it for me, not sure if the maintainer wants that behaviour though.

    var path = require('path');
    ...

    var filePath = path.isAbsolute(urlOrFile) ? urlOrFile : process.cwd() + '/' + urlOrFile
    u = url.format({
      protocol: 'file',
      pathname: url.parse(filePath).pathname,
      search: url.parse(filePath).query,
      slashes: true,
      hash: args || urlData.hash
    })

@CortinaCapoeira
Copy link

If you are using the command line tool a quick fix for unix is to use $(pwd):
electron-pdf $(pwd)/index.html index.pdf

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

3 participants