我需要找到将图表水平打印为pdf / image / sheet的方式。
我使用代码自动打印。
现在,我正在打印从“电子表格”选项卡创建的pdf,但是尽管有选项设置,但它始终会垂直打印。
它将漂亮的水平pdf保存在云端硬盘上,然后垂直打印。
在打印统计信息时,我需要将其水平放置。
这是我的带有选项的代码:
var requestData = {
"oAuthServiceName": "spreadsheets",
"oAuthUseToken": "always",
};
//spreadsheet id
var ssID = ss.getId()
//sheet id
var sID = ss.getSheetByName("Print").getSheetId();
//creating pdf
var pdf = UrlFetchApp.fetch("https://docs.google.com/spreadsheets/d/"+ssID+"/export?gid="+sID+"&portrait=false&size=letter&fitw=true&format=pdf",requestData).getBlob();
//folder to created pdf in
var folder = DriveApp.getFolderById("1RseEezmGT2gSBS9rgdV0E2ggRD5O6dyu")
//creating pdf in this folder with given name
var file = folder.createFile(pdf).setName("Chart")
var docID = file.getId()
var printerID = "02f4280c-9e83-da7d-d5ff-ca0f25ca03e3"
var docName = "Chart"
//starts printing
printGoogleDocument(docID, printerID, docName)
和
function printGoogleDocument(docID, printerID, docName) {
var ticket = {
version: "1.0",
print: {
color: {
type: "STANDARD_COLOR",
vendor_id: "Color"
},
duplex: {
type: "NO_DUPLEX"
}
}
};
var payload = {
"printerid" : printerID,
"title" : docName,
"content" : DriveApp.getFileById(docID).getBlob(),
"contentType": "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
});
因此,我在这里使用选项portrait=false
打印为横向。不起作用
赞赏任何横向打印解决方案。
答案 0 :(得分:0)
尝试在票证中加入page_orientation
:
var ticket = {
version: "1.0",
print: {
color: {
type: "STANDARD_COLOR",
vendor_id: "Color"
},
duplex: {
type: "NO_DUPLEX"
},
page_orientation: { //Added
type:1//or type:"LANDSCAPE"
}
}
};