-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Set the margin to pdf page #2295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I just spend the whole day searching how to apply margins to every page, with the "html" module and ran out of luck. Margins are such important elements when working with pdf. Any pointers are greatly appreciated. |
Duplicate of #1176 |
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. |
Problem is, that all these things should be concentrated in one issue and not 100 issues of some of the same aspects. |
@Uzlopak I disagree with that logic. That keeps the number of defects down, but you'll end up with one gigantic defect with hundreds of issues, and fixing one is not tracked or documented anywhere in a clear way. It seems there are a bunch of issues closed as a duplicate of #1176 without any actual solutions provided. Is there a solution to this margin issue specifically because I cannot find one anywhere? |
Hi guys, is there any solution available? I'm struggling with this problem, but I haven't found the way to solve it outside the library. |
So, if I understand it correctly, you are supposed to set margin by passing an array to the
But that doesn't work due to a bug in html2canvas, right? |
My best to set margin was
hope it helps someone fix troubles quickly |
If there is only one page, then this way is OK. However, if it is more than one page, there is no margin at the bottom of the first page and at the top of the second page. helpless😔 |
@Uzlopak Any updates? |
I am also looking for an update... |
Hi, does anyone know how to fix this? |
@Fernandogdo see #2924. |
maybe you should ask microsoft to remove the "new issue" button and instead everyone just posts directly. This way everything will be concentrated in one place instead of 100 different. /sarcasm |
You should see this in the right context. When I wrote this, html plugin was relatively new. I was the only maintainer and had bigger plans for this plugin. So it was easier for me to concentrate all issues regarding .html into one issue to handle it in a central place. 2 years passed. I have no time to program in this project. If your biggest concern is, that I closed it, then I just reopen it hereby. |
I think this issue should be closed. With [email protected] you can pass margins to the |
Instead of setting the format on the original jsPDF object, set the format on the addPage method like so:
|
just set marign in css. it's can work. |
//This seems to work for the most part : let doc = new jsPDF('p', 'pt', 'a4'); doc.html(document.getElementById('htmlData'), { pdf.output('dataurlnewwindow'); |
It doesn't work properly, every new page has a different top margin. My guess is that it applies the bottom margin of the previous page |
You can get the page width, define a custom padding value : const padding = 10; Then, in each element you add to your doc, such as doc.text, you set its x as pageWidth - padding : doc.text('my text', pageWidth - padding, my_Y, { align: "justify" }); |
Uh oh!
There was an error while loading. Please reload this page.
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:
I have a margin to set, but didn't find any way to set. Does anyone help me out here?
The text was updated successfully, but these errors were encountered: