Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Need some help with some Google Apps/HTML script!


  • Please log in to reply

#1
KFarley

KFarley

    New Member

  • Member
  • Pip
  • 1 posts

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.)

 

a1osyZP.png

 


  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP