Skip to Content
0
Jan 20, 2023 at 04:13 AM

SAPUI5 - How to avoid breaking images and tables despite adding page breaks?

215 Views

I am having a problem printing in SAPUI5 application.. I have a page formatted with HTML to print the whole page. But the problem are the table and SVG images; even though we applied page breaks, it is breaking the images and table.

Image pagebreak problem

I am using html2canvas and jsPDF to generate the page.

This is what I am trying: the HTML page is already created, I am converting the SVG images to normal image first, and then add it to the body-div, after which I'm generating the PDF document. The problem is the page break is not getting applied properlly. It's a dynamic page and generated according to the data selected to be generated.

let oImgData = null;
 let dataURL = null;
 let pages = Math.ceil(data.height / data.page.height);
   for (let i = 0; i \< pages; i++) {
     if (i != 0) {
       doc.addPage();
      }
     oImgData = data.ctx.getImageData(0, data.page.height \* i, data.page.width, data.page.height);
     dataURL = getData(oImgData, data.page.width, data.page.height);
    doc.addImage(dataURL, 'PNG', doc.margin.horiz, doc.margin.vert, doc.work.width, doc.work.height);
   }