KFarley
KFarley

Reputation: 115

Where in this code would I add custom sizes for the application?

I have created a script within Google Scripts Editor so that when a user clicks on a menu on the toolbar in Google Sheets it brings up an application box where users click to print.

However, i'm not sure how I could add custom sizes for that application box that appears without messing up the code.

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

function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index')
    .setSandboxMode(HtmlService.SandboxMode.NATIVE);
    SpreadsheetApp.getUi()
    .showModalDialog(html, 'Click the button below to print using the Google Cloud Print service.');
}

and the index.html code is:

<!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>

Below are image explanations of what the script does:

enter image description here

enter image description here

enter image description here

enter image description here

As you can see from the last image, that is where the problem is, the application box is too small to fit all of the information on it, therefore cutting it out.

-EDIT-

I managed to work out how to create the application box bigger, with help from a user going by Matt. However, even with the box bigger, the window size where the Google Cloud Print service is located is still small, no matter how big I make the outside application box. (See Image below for reference.)

enter image description here

Could anyone assist with making the inside box the full size of the outside box? Or just simply make it bigger?

Best Regards.

Upvotes: 1

Views: 76

Answers (1)

Matt
Matt

Reputation: 2851

Check out https://developers.google.com/apps-script/reference/base/ui#showmodaldialoguserinterface-title

var htmlOutput = HtmlService
     .createHtmlOutput('<p>A change of speed, a change of style...</p>')
     .setWidth(250)
     .setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My add-on');

Upvotes: 1

Related Questions