eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.05k stars 1.37k forks source link

Explicitly setting no margins still has a margin to the left #360

Open christianceb opened 3 years ago

christianceb commented 3 years ago

html2pdf.js version: 0.9.2

When you explicitly define no margins, there is still a little space to the left of the PDF. image

As you can see, the Y axis was respected but seemingly not X. This was the code I used

html2pdf()
  .set({
    margin: 0,
    html2canvas: {
      scale: 2,
    }
  })
  .from(document.querySelector(".parameters"))
  .save();

I also tried zero-ing out x and y in html2canvas but only resulted in an unpredictable behavior. Not exactly the right place to look at.

I have tried to replicate this issue on jspdf v1.4.1 using their preferred version of html2canvas that time which was 0.5.0-beta3. This did not yield the issue I was talking about: image

Happy to look at this but I'm swamped with work and schoolwork at the moment, maybe in the future.

oscars17 commented 3 years ago

any updates for that issue?

chinh2597 commented 3 years ago

i'm facing this issue too, did you found out how to fix that @oscars17

devarcher commented 3 years ago

this cleaned up the margin issue for me:

      // margin: [Vertical, Horizontal]
      margin: [0, -0.08],