Html2Pdf library is adding extra spacing on page-break

Discussão em 'Angular' iniciado por Saurav baid, Janeiro 2, 2025.

  1. Saurav baid

    Saurav baid Guest

    When I use the class .break-page, the extra space above the table is added (highlighted in red). I have tried using negative margin values, but it does not work.

    I want the table to move to the top of the new page when I apply .break-page and remove the extra spacing that is being applied on the table. What can be the possible solution?

    The code snippet of the function being called,

    function downloadPdf(
    pdfName?: string,
    param?: string,
    htmlElement?: ElementRef
    ): void {

    let opt = {
    margin: [4, 3, 2, 3],
    filename: pdfName + "_" + param + ".pdf",
    image: { type: "jpeg", quality: 1 },
    html2canvas: { scale: 2, width: 1100 },
    pagebreak: { mode: "css", before: ".break-page" },
    jsPDF: { unit: "em", format: "a4", orientation: "portrait" },
    };

    html2pdf()
    .set(opt)
    .from(htmlElement.nativeElement.innerHTML)
    .toContainer()
    .save();
    }


    [​IMG]

    Continue reading...

Compartilhe esta Página