I print a chart from Google sheets automatically with code. I save the chart as a png image then print it via Google Cloud Print.
The issue is that the image size on a paper is too small, I need to reduce margins or change anything so the image is filling almost all paper.
The size of the chart on an image file on the Drive is perfect! But when printing it gets too small. It might have something to do with paper size.
I've tried many variations of stating the margins anf their sizes (like media_size: {width_microns: 600000, height_microns:300000}, media size and fit to page options from here and here and none of them changed anything for my ticket.
Printer data:
Classic printer connected via Google Chrome
The defauls settings for cp__media: na_letter_8.5x11in (paper size type)
Here's my code:
//creates image of a chart in the folder
var docID = folder.createFile(chart.getBlob()).getId() // saves it as a file
var docName = "Chart"
//starts printing
printGoogleDocument(docID, docName)
function printGoogleDocument(docID, docName) {
var printerID = getPrinterList()
var ticket = {
version: "1.0",
print: {
color: {
type: "STANDARD_COLOR",
vendor_id: "Color"
},
duplex: {
type: "NO_DUPLEX"
},
page_orientation: {
type: 2//or type:"LANDSCAPE"
},
fit_to_page: {
type: 1//"FIT_TO_PAGE"
}
}
};
var payload = {
"printerid" : printerID,
"title" : docName,
"content" : DriveApp.getFileById(docID).getBlob(),
//DriveApp.getFileById(docID).getBlob(),
"contentType": "image/png",
//"application/pdf",
"ticket" : JSON.stringify(ticket)
};
var response = UrlFetchApp.fetch('https://www.google.com/cloudprint/submit', {
method: "POST",
payload: payload,
headers: {
Authorization: 'Bearer ' + getCloudPrintService().getAccessToken()
},
"muteHttpExceptions": true
});
}
Please help to make an image bigger on a printed sheet of paper.