toondaey / nestjs-pdf

Nest js pdf generator
MIT License
80 stars 37 forks source link

margin problem #193

Open diamond94618 opened 1 year ago

diamond94618 commented 1 year ago

Hello, Mr developer I have one problem using this lib. Currently I generate pdf using PDFService.toBuffer() function in my project. Everythings are ok. but I don't know how to change margins of pdf page. I googled whole day but still not found the way. plz give me advice. Thanks

alancghizzi commented 1 year ago

Hey man, i faced the same issue and found a possible solution for now. This lib uses html-pdf, so you can create an object that spreads inside the PDFService.toBuffer() function. The bad thing on this is the type, since the author didn't implement the type to extend html-pdf options, you have to ignore them for now (//@ts-ignore).

const options = {
    border: '2cm',
};

this.pdfService.toBuffer('yourtemplate', {
    // @ts-ignore
    ...options
});

Here's the options available in html-pdf which you can use as well. I saw you created another issue requesting how you can set header and footer margins, you can use the options of html-pdf. https://github.com/marcbachmann/node-html-pdf#options

Hope this helps you!