1

写作要求如何使用脚本增加内部HTML应用程序窗口的大小。如何增加HTML应用程序窗口的大小?

我目前正在创建Google表格工作表,并且我还在Google Apps脚本中创建了一个脚本,以便用户可以通过Google Cloud Print打印工作表。然而,当我点击打印,实际的云打印应用程序窗口相比,外箱是微小的(见下图的什么,我的意思是更好的代表性。)

enter image description here

所以箱子本身300 x 500,但里面的窗口是宽度的一半,因此切断了大部分窗口。我只想知道是否有任何方法可以让内部窗口变大或匹配外部应用程序框的大小?以下是我使用的完整代码。

function onOpen() { 
    SpreadsheetApp.getUi() 
     .createMenu('Click to print') 
     .addItem('Print from Google Cloud', 'openDialog') 
     .addToUi(); 
} 

function openDialog() { 

    var html = HtmlService.createHtmlOutputFromFile('Index') 
    .setWidth(300) 
    .setHeight(500) 
    .setSandboxMode(HtmlService.SandboxMode.NATIVE); 
    SpreadsheetApp.getUi() 
    .showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.'); 


} 

的index.html代码:

<!DOCTYPE html> 
<html> 
    <head> 
    <base target="_top"> 
    <script src="https://www.google.com/cloudprint/client/cpgadget.js"> 
</script> 
<script> 
    window.onload = function() { 
    var gadget = new cloudprint.Gadget(); 
    gadget.setPrintButton(
    cloudprint.Gadget.createDefaultPrintButton("button")); 
    var liabilityWaiver = waiver.getAs(MimeType.PDF); 
    gadget.setPrintDocument("url", "Test Page", "https://drive.google.com/open?id=0B3NraNAa2RhWSldiNklPVGI5OU0"); 
    } 
</script> 
    </head> 
    <body> 
    <div id="button"></div> 
    </body> 
</html> 

回答

2

我相信你所看到的是一个显示是太多,如果你调整箱尺寸为大型看看盒子下面,它更适合。

function onOpen() { 
 
    SpreadsheetApp.getUi() 
 
     .createMenu('Click to print') 
 
     .addItem('Print from Google Cloud', 'openDialog') 
 
     .addToUi(); 
 
} 
 

 
function openDialog() { 
 

 
    var html = HtmlService.createHtmlOutputFromFile('Index') 
 
    .setWidth(670) 
 
    .setHeight(500) 
 
    .setSandboxMode(HtmlService.SandboxMode.NATIVE); 
 
    SpreadsheetApp.getUi() 
 
    .showModalDialog(html, 'Click the button below, select a printer then adjust your settings and then click Print.'); 
 

 

 
}

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <base target="_top"> 
 
<script src="https://www.google.com/cloudprint/client/cpgadget.js"> 
 
</script> 
 
<script> 
 
    window.onload = function() { 
 
    var gadget = new cloudprint.Gadget(); 
 
    gadget.setPrintButton(
 
     cloudprint.Gadget.createDefaultPrintButton("print_button_container")); // div id to contain the button 
 
    gadget.setPrintDocument("url", "Test Page", "https://www.google.com/landing/cloudprint/testpage.pdf"); 
 
    gadget.openPrintDialog(); 
 
    } 
 
</script> 
 
    </head> 
 
    <body> 
 
    <div id="button"></div> 
 
    </body> 
 
</html>

钡磁材料来打印一个谷歌的电子表格

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <base target="_top"> 
 
<script src="https://www.google.com/cloudprint/client/cpgadget.js"> 
 
</script> 
 
<script> 
 
    window.onload = function() { 
 
    var gadget = new cloudprint.Gadget(); 
 
    gadget.setPrintButton(
 
     cloudprint.Gadget.createDefaultPrintButton("print_button_container")); // div id to contain the button 
 
    gadget.setPrintDocument("google.spreadsheet", "Test Page", "SPREADSHEET-ID-GOES-HERE"); 
 
    gadget.openPrintDialog(); 
 
    } 
 
</script> 
 
    </head> 
 
    <body> 
 
    <div id="button"></div> 
 
    </body> 
 
</html>

+0

哦,是的,我明白了。非常感谢,非常简单,但我很感激! – KFarley

+1

可能需要提出另一个问题,但我会问这里只是为了节省我的垃圾邮件问题。现在我可以看到所有的窗口,当我点击打印按钮时,什么都没有发生?这与编码有关吗? (可能是因为我对Google Apps脚本或HTML确实不熟悉。) – KFarley

+0

尝试使用我添加的index.html。现在没有任何按钮 - 直接打印机选择窗口 – OblongMedulla

相关问题