Hi all, I have been creating a Google Sheets worksheet for the past few days at work and I am at a stump. I have created a script using Google Apps Script and HTML that essentially creates a drop down menu in Google Sheets toolbar UI and once the user clicks the option in that drop down, they are able to print the worksheet through Google Cloud Print.
However, I get to the point where I would click to print the document, after setting the settings to what they need to be (Portrait, 1 Copy, etc...) and when I click the "Print" button, literally nothing happens. I've checked the script transcript and it says the script ran successfully, clearly not.
Below is the code I use in the script:
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.'); }
and the index.html code:
<!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("application/pdf", "PDF Application", base64EncodedPdf, "base64"); } </script> </head> <body> <div id="button"></div> </body> </html>
Can you guys see anything wrong in this code that could be causing the Google Cloud "Print" button to not do anything? Or is it an issue not regarding the code?
(Here is an image highlighting the button that doesn't work.)