devongovett/node-wkhtmltopdf

Pass options to `cover`

Closed this issue · 4 comments

I'm using this package to generate a PDF from HTML and it works like a charm. Except...

I cannot figure out how to pass my cover: "cover.html" parameter with options. As it stands, the automatic margins force my cover page into the constraints of about 10mm, as is the default.

I've tried the code below, but obviously it didn't work (nor should it).

    cover: `assets/cover.html --margin-top "10mm"`

I can't think of any other way to send my cover along with options. According to the wkhtmltopdf documentation, this should be allowed. Am I missing something, or would this require a PR?

zxlin commented

margin-top is a global option. you should be able to use:

{
  cover: 'assets/cover.html',
  marginTop: '10mm',
}

@zxlin Thank you for the response :)

You're right that it's a global option, but the thing is, I only want that to apply to the cover page. If I apply the global style of marginTop: "0mm" to the whole project, it ruins my headers. So what I'd like to be able to do (if possible) is apply the margins to just the cover.

My alternative is generate the document, then later prepend the cover pages with a different program. That's not ideal, but it's not the end of the world. Thoughts?

zxlin commented

I'm not sure if you can apply the margin to the cover only, can you try with the command line tool and see if it works as expected? Because it would be an upstream issue if the command line tool didn't do what you're expecting.

zxlin commented

Closing due to inactivity.