question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set the margin to pdf page

See original GitHub issue

I am using jsPDF version 1.5.3 and I want to convert HTML into PDF. I also want to add margin to each pages of PDF so that content should not get cut while splitting it to next page. I have written following code until now:

var pdf = new jsPDF('p', 'pt', 'a4');

var margin = {top: 10, right: 20, bottom: 10, left: 20};

pdf.html(document.getElementById('content'), {
      callback : function (pdf) {
          pdf.save('content.pdf');
      }
});

I have a margin to set, but didn’t find any way to set. Does anyone help me out here?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19

github_iconTop GitHub Comments

37reactions
Uzlopakcommented, Jun 3, 2019

@pedrovsp

Problem is, that all these things should be concentrated in one issue and not 100 issues of some of the same aspects.

19reactions
pedrovspcommented, Jun 3, 2019

Should this issue really be marked as a duplicate? From I what I understood this issue regards the specific problem of setting margins to PDFs with the .html() method, whereas issue #1176 is a broad discussion on the new .html(). Also, issue #1176 doesn’t seems to have solution nor discussion on this specific problem. Isn’t it better for this issue to stay open until we find a solution and keep the other issue less polluted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change Margins in PDF? - Adobe Support Community
It's pretty lame that it's so buried, but you actually can change the margins through the header and footer dialog box. Go under...
Read more >
How to Change the Margins on a PDF File - Techwalla
How to Change the Margins on a PDF File · Step 1. Open the file in Adobe Acrobat, then select "Document" and "Crop...
Read more >
Resize or add margins on PDF Online For Free using DeftPDF
How to resize PDF pages or Add Page Margins · Select “Add Margins and Padding” to change or add white spaces. You can...
Read more >
Show Page Margins in a PDF
Setting Up Your Workstation. Recommended Browser: Google Chrome. Adobe Acrobat DC. 1. It is recommended you configure your browser for .pdfs to open...
Read more >
How can I add a margin to all pages of a PDF document?
1 Answer 1 · Open the PDF document you want to add the margin to in Preview. · Go to File -> Print...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found