marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 544 forks source link

Is that possible to concat multiple HTML to make one PDF ? #104

Open dabaaaz opened 8 years ago

dabaaaz commented 8 years ago

Or concat some PDFs in juste one ?!

marcbachmann commented 8 years ago

no. please use another tool for that.

scurker commented 8 years ago

@fouzko Yes, it's possible to print different pages in one pdf with css - depending on how your html is setup.

With a structure like this:

<style>
  .page { page-break-before: always }
</style>
<div class="page">
...
</div>
<div class="page">
...
</div>

...anything contained within those page divs would be different pages in the PDF. I know this isn't exactly what you're asking, but the closest way to simulate "multiple" pdfs.

bigamasta commented 6 years ago

@scurker Helped a lot. Cheers.

marcbachmann commented 6 years ago

We really should put together some best practices. Abd write down all the limitations. Phantomjs and also chromium have many limitations which aren’t that obvious.

SamMatthewsIsACommonName commented 6 years ago

Mine are still seeming to ignore these break rules. Would the fact I'm using A4 size make a difference to how this would behave?

I also tried this additional to scurker's answer:

    page[size="A4"] {
  background: white;
  width: 21cm;
  height: 29.7cm;
  display: block;
  margin: 0 auto;
  margin-bottom: 0.5cm;
}
@media print {
  body, page[size="A4"] {
    margin: 0;
    box-shadow: 0;
  }
}
<page size="A4">
      <div class="page">
 /// content
</div>
</page>

Edit: ignore me... for some reason it's working now. I also set the html zoom level to 0.68 as recommended here: https://github.com/ariya/phantomjs/issues/12685

NikhilMutkekar commented 6 years ago

Thanks It did help!

karamjb commented 3 years ago

Thanks @scurker <style> .page { page-break-before: always } </style> helped my a lot