0

Am generating pdf by using pdfmake. PDF generating properly the problem here is it is generating border around the content. i tried to remove them by using layout"'noBorders' and other ways also. but no luck , can anyone sort out this issue. here is my code sample

html2canvas(document.getElementById('div2'), {
    onrendered: function (canvas2) {
        var data2 = canvas2.toDataURL();
        var docDefinition2 = {
            content: [{  
                layout: 'noBorders',
                image: data2, alignment: 'center',
                fit: [700, 700], margin: [40, 0, 0, 0], 
                pageBreak: 'after'
            }]
        };                         
        pdfMake.createPdf(docDefinition2).download('batch5df885f0-6e16-453e-83cb-b09d2e990bad.pdf');    
    }
});
Ignacio Ara
  • 2,476
  • 2
  • 26
  • 37
Sujatha
  • 182
  • 2
  • 13
  • border seems like it's the image borders than the pdf doc border. Got screenshot? – Marcia Ong Jul 04 '18 at 06:44
  • You have no borders in docDefinition, probably border is from canvas. Remove border in canvas. –  Jul 04 '18 at 08:46

1 Answers1

0

Add margin: 0; to the body tag in your css, and display: block; to the canvas tag in your css.

Example:

canvas {
        display:block;
    }

body {
    margin:0;
}