How to set margin only for first page
See original GitHub issueHi, i exporting pdf from an API and i draw, insert and set tables an images. In header i put an image and a title, set a margin top so i can see these elements and in details have a page breaks. In this case in second page the margin top persist and draw me a white space. I want to reset this margin but only if page if not the first.
` var pdf = new jsPDF(‘p’, ‘pt’, ‘letter’); pdf.setFont(‘DINBold’); pdf.setFontSize(22); pdf.setTextColor(26, 40, 88); pdf.text("Tabla ",350, 80); pdf.addImage(imgData, ‘JPEG’, 40, 40, 200, 50);
pdf.setFont('Times New Roman');
pdf.setFontSize(10);
pdf.setTextColor(0, 0, 0);
pdf.setDrawColor(104, 176, 224);
pdf.setFillColor(104, 176, 224);
pdf.rect(40, 136, 510, 20, 'FD');
pdf.rect(40, 256, 510, 20, 'FD');
pdf.rect(40, 356, 510, 20, 'FD');
pdf.setDrawColor(120, 197, 49);
pdf.setFillColor(120, 197, 49);
pdf.rect(550, 136, 20, 20, 'FD');
pdf.rect(550, 256, 20, 20, 'FD');
pdf.rect(550, 356, 20, 20, 'FD');
pdf.setDrawColor(221, 221, 221);
pdf.setFillColor(221, 221, 221);
//pdf.rect(40, 170, 530, 70, 'FD');
pdf.setTextColor(255, 255, 255);
pdf.text("Tabla",43, 150);
pdf.setTextColor(27, 40, 88);
pdf.text("Número: ",50, 186);
pdf.text("Fecha: ",350, 186);
pdf.text(datos.numeroCuenta,150, 186);
pdf.text(datos.fecha,450, 186);
pdf.autoTable(movimientos.columns, movimientos.rows, {
styles: {overflow: 'linebreak'},
columnStyles: {
fechaMovimiento: {columnWidth: 120},
descripcionMovimiento:{columnWidth:200},
},
margin: {top: 210},
addPageContent: function(data) {
pdf.setTextColor(255, 255, 255);
pdf.text("Tabla "+ datos.fecha + " "+ datos.fecha +" N° "+ datos.numeroCuenta);
}
});
pdf.save(“tabla.pdf”); ` Thanks in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How can you change the margins on the first page only?
1. Click on the first page and go into page layout and change margins and choose to apply to whole document. 2. Then...
Read more >Creating different margins on the first page of a word template
Insert a Section Break (Next Page) from Page Layout > Breaks · Click on the page you want to expand/narrow the margins. ·...
Read more >How to have different margins on the first page
Different margins = different section ... You may know that margins are a section property. In order to change the page margins (or...
Read more >How to Change Margin on One Page in MS Word
Once you've successfully set up the section breaks, you can start changing the margins for that section already. Go to the Layout tab...
Read more >Different margin on first page - TeX - LaTeX Stack Exchange
How can I achieve different margins only on the first page without doing pagebreaks by hand? Any trick (like using wrapfig or something...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try the following code
I know this is already closed but you can try this: Instead of margin, you can use startY.
startY: pdf.pageCount > 1? pdf.autoTableEndPosY() + 20 : 210
Enjoy!