I am using html2canvas to capture a div on my Calendar and open the image on a new window,then print it. But on the print preview,the image is not filling up the paper.There are always blanks up, down, left and right, I want it to fill the page.
This is set to "Fit to page width":
And scale 100% is worse:
Here is my code:
function printCalendar(){
var printMaxWidth = "1420px";
var printMaxHeight = "890px";
//Create the option to open a window
var option = 'width=' + printMaxWidth + ',height=' + printMaxHeight;
var calendartPrintWindow = window.open("", "", option);
//Open the document of the window
calendartPrintWindow.document.open();
//Html2canvas
html2canvas(document.querySelector("#calendarContainer")).then(canvas => {
//Insert the created html document inside it
calendartPrintWindow.document.write('<img src="'+canvas.toDataURL()+'"/>');
//Close the document the window
calendartPrintWindow.document.close();
//Print
setTimeout(function(){calendartPrintWindow.print();},100);});
}
"Fit to page width" looks good but it will be great when the image can fill the entire page.Is there and Ideas?Thanks.