Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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