bauhausjs / phantom-html2pdf

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

Runnings file #1

Closed JackMiszencin closed 8 years ago

JackMiszencin commented 10 years ago

Any time I try and include a path to the runnings file, I get no output. I've called convert as follows:

pdf.convert({'html': '/Users/jmiszencin/Projects/blah/src/public/outline_template.html', 'css': '/Users/jmiszencin/Projects/blah/src/public/css/outline.css', 'runnings': '/Users/jmiszencin/Documents/stuff.js'}, function(result){ console.log(result.getTmpPath()); })

Here's what my runnings file looks like:

module.exports = {width: '50in', height: '9in', margin: '1px'}

I'm clearly doing something wrong with either the way I'm calling the function or the way I'm writing my runnings file. What can I do to fix this? Thanks in advance.

markyoungdev commented 10 years ago

+1 interested in how this should be configured as well.

kongou-ae commented 9 years ago

+1

360disrupt commented 9 years ago

+1 And how to handle it with coffee, should there be standing plain js I guess.

runnings = "module.exports = { footer: {height: '1cm', contents: function(page) { return '<footer class=\"partner\"><p>In Kooperation mit</p><img src=\"./logo.png\"/></footer>'}} }"

does not work for me.

pejuam commented 9 years ago

Did you notice my comment (and PR) on this issue at https://github.com/bauhausjs/phantom-html2pdf/issues/9?

360disrupt commented 9 years ago

Yes, that is what I tried with my code above, but I didn't realize that your changes are not merged to this repo. I usually stick to the original version of the package for easier deployment with npm and to choose a specific version.

Now I added your repo as a dependency. Does your repo update with the rest of the code? Do you know if I can install and keep a fixed version?

terehov commented 9 years ago

Oh no, I missed it indeed! I've been on holidays and have probably overseen that mail. Sorry for that! I am going to merge ist later today and create a new npm version.

360disrupt commented 9 years ago

The fix worked for me, but

module.exports = { footer: {height: '3cm', contents: function(page) { return '<footer style="text-align: center" class="partner"><p>In Kooperation mit</p><img src="/Users/MasterG/Desktop/PROJEKTE/0-COMPANY/register/.tmp/serve/backend/pdf/logo.template.png"/></footer>'}} }

Does not display any image. Copying the tag directly into the html displays the image: <footer style="text-align: center" class="partner"><p>In Kooperation mit</p><img src="/Users/MasterG/Desktop/PROJEKTE/0-COMPANY/register/.tmp/serve/backend/pdf/logo.template.png"/></footer>

EDIT:

I also tried it with a Base64 encode image with <img src=\"...\".. & including the image in the style-tag, also base64 encoded as a background property. Both did not work for me.

I think this comment might be interesting: https://github.com/ariya/phantomjs/issues/12887 The issue, as we later found out is, that both header and footer are separate html documents when it comes to phantomjs. So they need to include their own css and js imports and so on. Same with images and all.

Which means, that the function paperSize probably needs to be async and waits until images, css & js is rendered.

lucasboleite commented 8 years ago

Any news on when this fixed will be merged?

dustin-H commented 8 years ago

Is there anything to merge?

lucasboleite commented 8 years ago

As pejuan commented on 17 Nov 2015, he fixed this issue and a PR is currently opened to merge his fixes into this repo.As far as I could tell, it's waiting for documentation updates since November 2015.

dustin-H commented 8 years ago

Ah, ok... I know... However I had no time to write docs for this and pejuan also seems to have no time, so it got stuck.

Sorry for that!

I just had a look again on this... It doesn't seems to be needed to write docs.

I'm looking forward to merge and publish in the next two days. Sorry for the long waiting-time.