Git Product home page Git Product logo

html2pdf.it's Introduction

Generate PDFs from any web-page. You need Node.js to run it.

See it in action at: html2pdf.it.

Works out of the box on both Windows and Ubuntu. On Mac you need to:

brew install phantomjs

To get started you need to clone the repository, cd to it and run:

npm install

Running webserver locally

node open.js

This also opens your web-browser pointing to your locally running html2pdf.it:

Running webserver

node .

If you want to host html2pdf.it yourself, you will have to ask your host if they support hosting Node.js applications.

If your host does not support Node.js, you'll need to find a new host that does. Check out Heroku or Nodejitsu for example.

Running tests

npm test

Page breaks

You can use the CSS attribute:

page-break-before: always;

Data URIs

You can use data URIs like the following to generate PDFs for arbitrary HTML:

data:text/html;encoding=utf-8,<h1>Hello</h1>

As described on Wikipedia, the data URI should have the following format:

data:[<media type>][;base64],<data>

License

MIT

html2pdf.it's People

Contributors

ebdrup avatar edm00se avatar gbrault avatar gurix avatar jamescdavis avatar kaltsimon avatar krokhale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html2pdf.it's Issues

New Page

Is it possible to tell html2pdf when to start a new page? If not, it would be cool if you could just insert something into the html and html2pdf would start a new page

Installing Phantom in Mac OS X El Capitan

The command provided in the readme file brew install phantomjs does not work with El Capitan, at least for me it shows the next error:

phantomjs: This formula either does not compile or function as expected on OS X versions newer than Yosemite due to an upstream incompatibility. Error: An unsatisfied requirement failed this build.

To install and get it working I used the following command:

sudo npm install phantom phantomjs -g

Add Bookmarks in PDF?

I believe that may be based on the heading tags.
I do not have much knowledge in js, but may be the way.
:D 👍

alt text

Local Installation authentication

I have installed the service on my intranet, the problem that i am facing is when i try to convert a page that uses authentication, i am getting an error 401, how can i pass the user and password to the request and phantomjs process?

Export Format - One Long Page

Hello,
Could you add a Format to chose the page width (A2, A3, A4, etc...) yet print it as a one long page.

This more resembles the experience watching a website.

Thank You.

adding header footers js causes blank page

Hi (brilliant effort incidentally) ..

adding UL's causes blank pages when using header footer JS: here is my example run through your site - replace the UL block with text and it works fine. ( I removed the spurious } on the main page example) :

<title></title>
  • Super great system
  • 25 year warranty
  • Highest efficiency
  • Looks fantastic
  • Easy to maintain
<script type="text/javascript"> //setting up headers and footers for html2pdf var html2pdf = { header: { height: "1cm", contents: '
page {{pageNumber}} of {{totalPages}}
' }, footer: { height: "1cm", contents: '
page {{pageNumber}} of {{totalPages}}
' } }; </script>
</body>

Filename not quoted

If the filename specified includes spaces, some browsers (e.g. Firefox) will truncate the filename at the first space because it is not properly quoted in the Content-disposition.

Something odd is happening with the zoom of this page; very interesting

So while making a bookmarklet I was testing on Mozilla Developer Pages, specifically looking up the document page and it's properties (as I am just learning all this lol), and encountered a very odd occurance with the zoom levels. So far my bookmarklet has worked perfectly every where else.

Anyway, here is the URL used and corresponding outcome:
(FYI initially I also had the '&download=true' incorporated, but removed it for demonstration here)

http://www.html2pdf.it/?url=https://developer.mozilla.org/en-US/docs/Web/API/Document&zoom=9
http://www.html2pdf.it/?url=https://developer.mozilla.org/en-US/docs/Web/API/Document&zoom=0.1
http://www.html2pdf.it/?url=https://developer.mozilla.org/en-US/docs/Web/API/Document&zoom=0.01

9 considerabally shrunk the page!
0.1 enlarged the page!
0.01 cut off 99% of the page!

Also quick question here because don't want to start new ticket: Is it easy to route my bookmarklet through a local server on my PC so I don't contribute to your bandwidth bill? I honestly feel that if I switched the URL from your web address to my local address that it would work, but I've ran into many a problems where you can't do something like that. Something about xhr or javascript being unable to execute local stuff on client side due to protection of the user (chrome sandbox maybe?) Lol you can tell I don't know much at all, but always learning.

Another reason why I ask, is the first time I tried to execute my bookmarkelt

javascript: void(open('https://www.html2pdf.it/?url=' + encodeURIComponent(document.location) + '&download=true&filename=' + encodeURIComponent(document.title)))

it introduced a page that said this is unsafe to visit from your connection; pretty confident it was the 'Your connection is not private"

Header and Footer cause content to render blank

When including either a header or a footere, or both, my content renders nothing. But without these two options, it renders just fine. I saw the other issue report, but nothing ever came of it.

Your web site can't convert my web page(((

If i try to convert "www.adaperio.ru" web site - i am getting blank PDF file. Can you please help me with a clue? Maybe i need something to change in my HTML code?

What might be the problem?

Thank you for cool project!

What is html2pdf.it production phantomjs configuration?

Hi,
this is not really issue but I am trying to implement pdf generation with phantomjs on nodejs server with git://github.com/sgentle/phantomjs-node.git module.
I am not doing anything fancy . I want 1 A4 page with 2 columns (in table layout). 1 column is text and 2nd column is horizontally aligned picture. Had to set it with background css property because img tag was causing really weird results and picture was never proper size.

When I use your web tool it renders page correctly , when i use my implementation, which is just plain

page.setContent(html, url, function(status, err){
            if (status !== 'success') return next(err);
                page.render(tmpFile, function() {
                    page.close();
                    return next(null, tmpFile);
                    //console.log('PDF file: '+ filename + ' was generated');
                });
        });

the top part of picture is on 1st page and the bottom part is rendered on 2nd page. What configuration you use for phantomjs ? pageSize, viewPort , margins?

Thanks a lot, any help would be appreciated.

Update to phantomjs >= 2.0 to support font face

It would be great to have the phantomjs upgraded to a version >= 2.0. These versions support CSS font face, enabling the user to use nearly any font.

In order to update manually, the only thing to do is, to download the current version of phantomjs and copy it into the bin folder of the html2pdf.it installation.

browser shows "something broke"

pdf: /home/murali/programs/gitbag/html2pdf.it/bin/phantomjs: 1: /home/murali/programs/gitbag/html2pdf.it/bin/phantomjs: Syntax error: "(" unexpected Error: Wrong code: 2
at ChildProcess. (/home/murali/programs/gitbag/html2pdf.it/lib/webservices/pdf.js:99:19)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Socket. (child_process.js:979:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:466:12)

Header and Footer is not working

I'm using your app and have included the js file for header and footer. But it seems doesn't work. I got normal pdf to be generated without header and footer. Any help would be greatful.

Huge blank space above header

Hello, I'm working with my own installation of html2pdf, and I got a problem that I can seem to figure out.

My html is ok, when I generate the pdf from your page, it works great, but in my installation a huge white space appears above the header.

It's not css, br, p, or anything like that. When I set the header height to 1cm, the white space get smaller, but the header content gets cropped. If I set the correct height (5cm), the white space increases too.

Any idea what it could be?
capturar

Installation on Ubuntu 13 VM

Thanks for a great package!

These are the steps I went through to get it up and running on Ubuntu 13, I'm not a linux guy so please tell me if I did something wrong.

  1. I got access denied error when I tried to create my pdf, and therefore I just added chmod -R 777, dunno which folder I should add the permissions to so I added it to the full structure to get things running.

  2. I got an error
    "error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory" and found instructions to install libfontconfig1. After that it works, but the fonts are not entirely correct. Perhaps there are some other font library I should install aswell?

These are the steps I went through:

apt-get install git
apt-get install nodejs
apt-get install npm
apt-get install libfontconfig1

git clone https://github.com/Muscula/html2pdf.it.git
cd html2pdf.it
npm install
chmod -R 777 *

nodejs lib/app.js

Header and Footer not working with images

The var html2pdf does not seem to support images for header and footer. I keep getting either blank space or the alt attribute where the images should be. Is this a known issue ?

Question: Which font-types are supported?

I just wanted to ask which font-types are supported, as it seems that if I use a custom font via '@font-face' (e.g. MetaWeb-Book) the final PDF uses DejaVu-Sans to render the font.
Is there a list available where I could pick a supported font which is similar to the one used?

Error: spawn EACCES

When I run my server I get following error:

Something broke!

In console I get

Error: spawn EACCES at exports._errnoException (util.js:746:11) at ChildProcess.spawn (child_process.js:1169:11) at exports.spawn (child_process.js:999:9) at generatePdf (/var/zpanel/hostdata/zadmin/public_html/html2pdf/lib/webservices/pdf.js:85:22) at Request._callback (/var/zpanel/hostdata/zadmin/public_html//html2pdf/lib/webservices/pdf.js:68:4) at Request.self.callback (/var/zpanel/hostdata/zadmin/public_html/html2pdf/node_modules/request/request.js:344:22) at Request.emit (events.js:110:17) at Request.<anonymous> (/var/zpanel/hostdata/zadmin/public_html/html2pdf/node_modules/request/request.js:1239:14) at Request.emit (events.js:129:20) at IncomingMessage.<anonymous> (/var/zpanel/hostdata/zadmin/public_html/html2pdf/node_modules/request/request.js:1187:12) ::ffff:178.143.102.198 - - [29/Mar/2016:11:36:48 +0000] "GET /?url=mu-url%3A8080&download=false&format=A4&downloadToken=1459251408405&orientation=portrait&margin=1cm HTTP/1.1" 500 16 "http:/my-url:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"

Do you have any idea where could be the problem?

Boot startup on Ubuntu 13

(solved! I needed to change to the directory to get the service find the path for the generated pdf, updated script below)

This is my upstart (apt-get upstart) service (/etc/init/html2pdf.conf)

it runs on reboot, and otherwise run with sudo /sbin/init

#!upstart
description "nodejs running html2pdf"
author "joeriks"

start on runlevel [2345]
stop on runlevel [016]

# automatically restart if it crashes
respawn
respawn limit 99 5

script

    export HOME="/home/azureuser/html2pdf.it"
    # I found this to be necessary to get the right paths
    cd /home/azureuser/html2pdf.it
    exec sudo -u azureuser /usr/bin/nodejs lib/app.js >> /var/log/html2pdf.log 2>$1

end script

Integrate it to a Node.JS or Sails.JS app

Hi there!
First of all, I must to tell you CONGRATULATIONS for such amazing project. I'm developing a Sails.JS application but also I use to use Node.JS. In both cases I need to generate some PDF files to send and email with the registration form attached.

I was searching for some examples and the best one for me is this one. So, I would like to know how to integrate or embed this amazing tool in my Sails or Node js app?

Or I just can fork the project and deploy it to Heroku to have my own html2pdf server?
I hope you could help me out.

Thanks in advance!

Page too big

Since you've updated html2pdf to 1.5, a screen which content fitted one page before, now takes one and a half pages. Everything just got bigger. Is there a way to get the same results as before?

Adding a Header / Footer removes body content

I was trying out the header/footer function, but found that it removes the content in the body. Also happens with the html in inhttps://github.com/Muscula/html2pdf.it/blob/master/test/integration/pdf.header.footer.spec.js when I try.

unable to print pdf browser is showing "something broke"

pdf: /home/ist-116/NodeServer/html2pdf.it-master/bin/phantomjs: 1: /home/ist-116/NodeServer/html2pdf.it-master/bin/phantomjs: Syntax error: "(" unexpected

Error: Wrong code: 2
at ChildProcess. (/home/ist-116/NodeServer/html2pdf.it-master/lib/webservices/pdf.js:99:19)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Socket. (child_process.js:1183:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:485:12)
::ffff:127.0.0.1 - - [11/Dec/2015:14:16:27 +0000] "GET /?url=localhost%3A8080&download=false&format=A4&downloadToken=1449843387206&orientation=portrait&margin=1cm HTTP/1.1" 500 16 "http://localhost:8080/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"

NPM Package

I tried to find it on npm but it seems it is no package Is it planned to provide this as a npm package or is it already a package and I'm missing something? This would be great, because it makes installation & deployment with continuous integration tools more easy.

npm package

Is there any chance of getting an npm package with require dependencies so this can be added to an existing node project rather than just pulling the repo?

i was searching arround for something like npm install html2pdf-it

Filesize: Difference between local phantomjs and your hosted version

Hi,
when I convert a page with your site html2pdf.it it is really small as text seems to be rendered as text, I can select it afterwards with Adobe PDF selection tools. When I clone this repo and use it on my mac with phantomjs 2.0 I got a huge PDF file size. When I try to select text in a PDF viewer I can't, I guess the text is rendered as image - that would explain the huge filesize.

So the question is: which phantomjs version is your server using und where do you host? Heroku?

This might be related to ariya/phantomjs#12685.

Thanks, BR, toovy

Suggestion: Add mime type

Hello,
Just came up with the following issue:
On hosts which process php within html files, I get the following warning:

" returns content type application/x-httpd-lsphp. You must point html2pdf.it to HTML or TEXT content"

The HTML file was a valid generated but the client added the apache handler to php.

Add PNG support

PhantomJS can generate both PDF and PNG, we juts need to pass parameter for it.

still ssl issue

I am using html2pdf.it for my project and had some trouble going online.

i.e the following page https://laufbahndiagnostik.psychologie.zhaw.ch/de/helena/sessions/gXyg1rEdtVLh5lTolkO2JKNOd results

Unable to load the address (null): https://laufbahndiagnostik.psychologie.zhaw.ch/de/helena/sessions/gXyg1rEdtVLh5lTolkO2JKNOd fail

What I did then was runnning a new instance on heroku in with I ignored ssl errors with --ignore-ssl-errors=true. That seems to be the trick but indicates that my certification is wrong. But as far as I can see is everything normal.

https___laufbahndiagnostik_psychologie_zhaw_ch_de_helena_sessions_gxyg1redtvlh5ltolko2jknod

I guess the problem is phantomjs because when I run everything locally It works fine. Any idea?

Phatom.js version?

Upon submitting a url after setting up install:

pdf: /var/www/pdf/bin/phantomjs: 1: /var/www/pdf/bin/phantomjs: 
pdf: ELF����: not found
pdf: 

pdf: /var/www/pdf/bin/phantomjs: 1: /var/www/pdf/bin/phantomjs: 
pdf: ��O!: not found
pdf: 

pdf: /var/www/pdf/bin/phantomjs: 1: /var/www/pdf/bin/phantomjs: @@��L�@8: not found
/var/www/pdf/bin/phantomjs: 22: /var/www/pdf/bin/phantomjs: !#��X��¿½!�����: not found
/var/www/pdf/bin/phantomjs: 23: /var/www/pdf/bin/phantomjs: �¿½: not found
/var/www/pdf/bin/phantomjs: 24: /var/www/pdf/bin/phantomjs: ��������������������
                                                                                : not found
/var/www/pdf/bin/phantomjs: 25: /var/www/pdf/bin/phantomjs: ��������: not found
/var/www/pdf/bin/phantomjs: 26: /var/www/pdf/bin/phantomjs: ������: not found
/var/www/pdf/bin/phantomjs: 27: /var/www/pdf/bin/phantomjs: ������������������������������: not found
/var/www/pdf/bin/phantomjs: 28: /var/www/pdf/bin/phantomjs: ������������������������������: not found
/var/www/pdf/bin/phantomjs: 29: /var/www/pdf/bin/phantomjs: �������: not found
/var/www/pdf/bin/phantomjs: 30: /var/www/pdf/bin/phantomjs: �������: not found
/var/www/pdf/bin/phantomjs: 31: /var/www/pdf/bin/phantomjs: �: not found
/var/www/pdf/bin/phantomjs: 33: /var/www/pdf/bin/phantomjs: y

                                                             ������0ӯk�: not found
/var/www/pdf/bin/phantomjs: 34: /var/www/pdf/bin/phantomjs: Syntax error: ")" unexpected

pdf: /var/www/pdf/bin/phantomjs: 33: /var/www/pdf/bin/phantomjs: 
pdf��O��: not found
pdf: 

Error: Wrong code: 2
    at ChildProcess.<anonymous> (/var/www/pdf/lib/webservices/pdf.js:79:19)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)
174.98.234.206 - - [Sun, 15 Dec 2013 15:34:50 GMT] "GET /?url=http%3A%2F%2Fjordancauley.com&download=false&format=A4&downloadToken=1387121692202&orientation=portrait HTTP/1.1" 500 16 "http://pdf.cauley.co:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

SSL not supported?

I tried to use html2pdf.it to create pdfs that works well. Now i am getting the following error

Unable to load the address (null): https://laufbahndiagnostik-staging.herokuapp.com/de/questionary_sessions/NfOop3jM1eTlEspkIsN8ZKTDy fail 

So obviously it does not support ssl. Is this just an issue of the underlying phantom.js driver?

Option for offline html

I really like your app. Very good output.
The only thing I'm missing is the option to turn offline html into pdf.

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.