pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Different pageMargins/page

Open India0 opened this issue 9 years ago • 8 comments

Hy! Is there any way to change pageMargins dynamically? I would like to use higher margin on the last page becouse it contains more content... Thx your help!

India0 avatar May 16 '17 13:05 India0

Are there any workarounds for this?

leeeylaaa avatar May 16 '17 13:05 leeeylaaa

My footer contains the date and the page number/count:

`my_content.push(...)

var my_pdf = { pageOrientation: "landscape", pageMargins: [20,40,20,40], content: my_content, footer: function (page, pages) {return [ {canvas: [{type: "line", lineWidth: 2, x1: 10, y1: 10, x2: 830, y2: 10}]}, {columns: [ {text: my_date.toString(), style: "doc_footer", alignment: "left"}, {tect: page.toString() + " /" + pages.toString(), style "doc_footer", alignment: "right"} ]} ] }, styles: {...} ` At the end of my report I wanted to display the clause (which contains more data), so I added an if structure, but the footer was too low to display the full clause:

footer: function (page, pages) { if (page == pages) { return [{ table: { widths: [80,"*"], body: [ [{text: "Made:", style: "doc_footer"},{text: "3 copies", style: "doc_footer"}], [{text: "One copy:", style: "doc_footer"},{text: pages + " page", style: "doc_footer"}], ..., ..., ... ] }, layout: "noBorders" }] } else {...the first mentioned code...} }

India0 avatar May 17 '17 06:05 India0

No idea? How can I get total page number in the content section?

India0 avatar May 29 '17 13:05 India0

Feature request: https://github.com/bpampuch/pdfmake/issues/368

liborm85 avatar Jul 26 '17 07:07 liborm85

Is there any way to set pagemargins dynamically? I'm asking because I'm trying to generate reports clientside but the reports have different headers and footers. I can get it to dynamically write out the correct headers but because the header content changes, the page margins need to also get adjusted otherwise there is overlap or two much space depending on what is in the header.

I was hoping there was a way to dynamically reset the pageMargin property before outputting a new page using pagebreakafter. Is there anybody who's done something similar? I saw the example where there's a method that returns the current page when setting .pageMargin value but because the reports generated aren't known, I need the ability to set the pageMargins. Thanks in advance.

mouaxiong avatar Jul 10 '19 17:07 mouaxiong

I was looking for dynamic margins too, as @mouaxiong.

In my case some pages many not have header (specially the first page). If I have to put the margins to cover the headers of the whole document, the first page gets an undesired gap on the top.

Other case is that left pages and right pages have different headers height.

Why is the reason for this feature to be closed?

ditiem avatar Jul 25 '19 14:07 ditiem

any solution around this yet?

mrgaganchohan avatar Nov 20 '20 02:11 mrgaganchohan

Any solution to this yet?

MichaelAffanyi avatar May 20 '25 10:05 MichaelAffanyi