bauhausjs / phantom-html2pdf

Node module to generate PDFs from HTML via PhantomJS
MIT License
112 stars 47 forks source link

what should go in the "runnings" property ? #9

Closed kingroryg closed 8 years ago

kingroryg commented 9 years ago

MY options look like this ,

var options = {
        "html": "print.html",
        "paperSize": { 
            format: 'A4', 
            orientation: 'portrait', 
            border: '1cm' 
        },
        "deleteOnAction": true
    } ;

However, I have no idea as to what should go inside the runnings property .

pejuam commented 9 years ago

I did something like this to get customized header and footer:

var runnings = "module.exports = { header: {height: '1cm', contents: function(page) { return page === 1 ? '' : '<div style=\"text-align: center\">Title</div>' }}, footer: {height: '1cm', contents: function(page, pages) { return '<div style=\"text-align: center\">' + page + '/' + pages + '</div>'}} }"
...
"runnings" : runnings

However, conversion implementation seem to be buggy. I made two fixes into code before conversion was made successfully. Fixes are found here: https://github.com/pejuam/phantom-html2pdf/commits/master

terehov commented 9 years ago

Would you mind to update the docs as well? Thanks!

dustin-H commented 9 years ago

@saru95 Is this solved for you with the answer from @pejuam?

befreestudios commented 8 years ago

Can someone please explain what the "runnings" file does and provide an example of it? This seems to be an important item that is completely undocumented, unless I'm missing something.

Thanks in advance.

dustin-H commented 8 years ago

@befreestudios https://github.com/bauhausjs/phantom-html2pdf#runnings-file

befreestudios commented 8 years ago

@dustin-H Not sure how I missed that.. (bows head in shame, lol)

BTW awesome little lib, nice job. Does exactly what we need with minimal configuration.

dustin-H commented 8 years ago

Thanks! Credits to @PhilippCh for initially creating this!