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

相關問題