burnnat / page-sizer

Google Docs add-on to to specify custom page sizes.
MIT License
7 stars 4 forks source link

no more available on Google Workspace #9

Open Iragael opened 9 months ago

Iragael commented 9 months ago

Page Sizer is no more available on Google Workspace marketplace (404 error page) Please help!

https://chrome.google.com/webstore/detail/page-sizer/acgkneeneageffjinlglednnehpelffb

GeorgeLLL commented 9 months ago

I rely on Page Sizer too. This is a major problem. It's bad enough that I can't download and install it on another account, via the Google store, but they removed it from the account I was already using it on! Help!

failingapbio commented 9 months ago

@Iragael @GeorgeLLL Paste this and tinker with the sizes in the source code. Not perfect, but works.

/* Easy way to configure the page size in Google Docs to any of the A sizes in portrait or landscape: 4A0, 2A0, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10

Google Docs does not support custom page sizes, with this addon you can set any of the A* page sizes and toggle between portrait and landscape mode.

Size Width x Height (mm) Width x Height (in) 4A0 1682 x 2378 mm 66.2 x 93.6 in 2A0 1189 x 1682 mm 46.8 x 66.2 in A0 841 x 1189 mm 33.1 x 46.8 in A1 594 x 841 mm 23.4 x 33.1 in A2 420 x 594 mm 16.5 x 23.4 in A3 297 x 420 mm 11.7 x 16.5 in A4 210 x 297 mm 8.3 x 11.7 in A5 148 x 210 mm 5.8 x 8.3 in A6 105 x 148 mm 4.1 x 5.8 in A7 74 x 105 mm 2.9 x 4.1 in A8 52 x 74 mm 2.0 x 2.9 in A9 37 x 52 mm 1.5 x 2.0 in A10 26 x 37 mm 1.0 x 1.5 in DL 220 x 110 mm C4 229 x 324 mm C5 162 x 229 mm C6 114 x 162 mm C6/5 114 x 229 mm

This addon only sets the page size and page orientation. Use File → Page setup to set all other page settings. As that dialog does not support custom page sizes it will reset your page size. Simply use the Add-ons → Set A Page Size menu again to set your custom page size. /

var sizes_paper_data = { "4A0 (1682 x 2378 mm)" : { "PAGE_WIDTH": 4768, "PAGE_HEIGHT": 6741 }, "2A0 (1189 x 1682 mm)" : { "PAGE_WIDTH": 3370, "PAGE_HEIGHT": 4768 }, "A0 (841 x 1189 mm)" : { "PAGE_WIDTH": 2384, "PAGE_HEIGHT": 3370 }, "A1 (594 x 841 mm)" : { "PAGE_WIDTH": 1684, "PAGE_HEIGHT": 2384 }, "A2 (420 x 594 mm)" : { "PAGE_WIDTH": 1191, "PAGE_HEIGHT": 1684 }, "A3 (297 x 420 mm)" : { "PAGE_WIDTH": 842 , "PAGE_HEIGHT": 1191 }, "A4 (210 x 297 mm)" : { "PAGE_WIDTH": 595 , "PAGE_HEIGHT": 842 }, "A5 (148 x 210 mm)" : { "PAGE_WIDTH": 420 , "PAGE_HEIGHT": 595 }, "A6 (105 x 148 mm)" : { "PAGE_WIDTH": 298 , "PAGE_HEIGHT": 420 }, "A7 (74 x 105 mm)" : { "PAGE_WIDTH": 210 , "PAGE_HEIGHT": 298 }, "A8 (52 x 74 mm)" : { "PAGE_WIDTH": 147 , "PAGE_HEIGHT": 210 }, "A9 (37 x 52 mm)" : { "PAGE_WIDTH": 105 , "PAGE_HEIGHT": 147 }, "A10 (26 x 37 mm)" : { "PAGE_WIDTH": 74 , "PAGE_HEIGHT": 105 }, };

var sizes_envelopes_data = { "DL (220 x 110 mm)" : { "PAGE_WIDTH": 624 , "PAGE_HEIGHT": 312 }, "C4 (229 x 324 mm)" : { "PAGE_WIDTH": 649 , "PAGE_HEIGHT": 918 }, "C5 (229 x 162 mm)" : { "PAGE_WIDTH": 649 , "PAGE_HEIGHT": 459 }, "C6 (162 x 114 mm)" : { "PAGE_WIDTH": 459 , "PAGE_HEIGHT": 323 }, "C6/5 (229 x 114 mm)" : { "PAGE_WIDTH": 649 , "PAGE_HEIGHT": 323 }, };

var sizes_paper = Object.keys(sizes_paper_data); var sizes_envelopes = Object.keys(sizes_envelopes_data);

function funcName(size) { return Utilities.computeDigest(Utilities.DigestAlgorithm.MD2, size).reduce(function(result, value) { return result.concat(Math.abs(value)); },"set"); }

eval(sizes_paper.map(function(size) { return function ${funcName(size)}() { setPageSize(sizes_paper_data["${size}"]) } }).join(';\n'));

eval(sizes_envelopes.map(function(size) { return function ${funcName(size)}() { setPageSize(sizes_envelopes_data["${size}"]) } }).join(';\n'));

function onOpen(e) { var ui = DocumentApp.getUi(); var menu = ui.createAddonMenu(); sizes_paper.forEach(function(size) { menu.addItem(size, funcName(size)); }); menu.addSeparator(); sizes_envelopes.forEach(function(size) { menu.addItem(size, funcName(size)); }); menu.addSeparator().addItem("Portrait ⇄ Landscape", "togglePortraitLandscape").addToUi(); }

function onInstall(e) { onOpen(e); }

function setPageSize(size_dict) { DocumentApp.getActiveDocument().getBody().setAttributes(size_dict); }

function togglePortraitLandscape() { var body = DocumentApp.getActiveDocument().getBody(); var attributes = body.getAttributes(); var width = attributes["PAGE_WIDTH"]; var height = attributes["PAGE_HEIGHT"]; body.setAttributes({ "PAGE_WIDTH" : height, "PAGE_HEIGHT" : width, }); }

/*

Copyright (c) 2017 Zalando SE / Schlomo Schapiro

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

Samplik commented 8 months ago

@Lolol4572, where have I to paste it? Need to make custom page size too.

YisroelTech commented 6 months ago

Page Sizer is no more available on Google Workspace marketplace (404 error page) Please help!

https://chrome.google.com/webstore/detail/page-sizer/acgkneeneageffjinlglednnehpelffb

I rely on Page Sizer too. This is a major problem. It's bad enough that I can't download and install it on another account, via the Google store, but they removed it from the account I was already using it on! Help!

If you simply want to use it in specific Google Docs, and it's worth the effort for you, you can simply copy the code of the add-on into that specific Doc, and it works well.

Here's a step by step:

  1. Open to the Doc you want to run it on
  2. Click on Extensions > Apps Script
  3. In the new page that opens (on https://script.google.com), click on Untitled project on the top and give the project a name (e.g. Page Sizer Script)
  4. Go to this page https://github.com/burnnat/page-sizer/blob/master/Page%20Sizer/Code.js (in this Page Sizer project) and press the Copy icon on top of the code (or copy the code from https://raw.githubusercontent.com/burnnat/page-sizer/master/Page%20Sizer/Code.js)
  5. Go back to the Apps Script page and click on the Code.gs in the left pane, then paste the copied code into the box (replacing all the text that was there before), and press Save Project
  6. Now repeat the same copying with the HTML code from https://github.com/burnnat/page-sizer/blob/master/Page%20Sizer/Dialog.html (raw https://raw.githubusercontent.com/burnnat/page-sizer/master/Page%20Sizer/Dialog.html)
  7. Go again to the Apps Script page, click the + sign next to Files, choose HTML, and in the name put Dialog. Paste the copied HTML code and press Save Project
  8. Now you can close the App Script page, and go back to the Google Doc. Refresh the page, and wait until it fully loads
  9. Click on Extensions and you should see there your script listed! (Page Resizer Script, select it and press Set page size...
  10. (The first time you run it on a Doc you will need to give it Authorization, it will pop up an Authorization required, click OK, it will bring you a login screen to select your Google Account, then it will show a Google hasn’t verified this app window, click Advanced and then Go to Page Sizer Script (unsafe), and then Allow. Then go back to the Doc and run it again)
  11. It will show Running Script, and then popup with a window to enter the custom size!
GeorgeLLL commented 6 months ago

Thanks for the advice. I sometimes need to define a non-standard (unique) page size, not an ISO or other standard paper size, so I will give @YisroelTech's instructions a try next time I need this. Thanks, again.