Created
October 5, 2025 11:28
-
-
Save lzlrd/00fc5f80c8753e168e5d1e00b447a1b6 to your computer and use it in GitHub Desktop.
Google Slides to PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var atag = "punch-viewer-page-wrapper", | |
| btag = "-caption", | |
| ctag = "aria-setsize", | |
| dtag = "aria-posinset", | |
| msvg = document.getElementsByTagName("svg"), | |
| node = document.querySelectorAll('[class$="' + btag + '"]')[0], | |
| view = document.getElementsByClassName(atag)[0], | |
| size = node.getAttribute(ctag), | |
| data = "", | |
| func = () => { | |
| data += msvg[0].outerHTML; | |
| if ((i = node.getAttribute(dtag)) == size) { | |
| escapeHTMLPolicy = trustedTypes.createPolicy("forceInner", { | |
| createHTML: (to_escape) => to_escape, | |
| }); | |
| document.write(escapeHTMLPolicy.createHTML(data)); | |
| let style = document.createElement("style"); | |
| style.textContent = ` | |
| @media print { | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| } | |
| svg { | |
| display: block; | |
| page-break-after: always; | |
| width: 100%; | |
| height: auto; | |
| margin: auto; | |
| } | |
| div { | |
| page-break-after: always; | |
| } | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| setTimeout(() => window.print(), 1000); | |
| } else { | |
| view.click(); | |
| setTimeout(func, 10); | |
| } | |
| }; | |
| func(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var atag="punch-viewer-page-wrapper",btag="-caption",ctag="aria-setsize",dtag="aria-posinset",msvg=document.getElementsByTagName("svg"),node=document.querySelectorAll('[class$="'+btag+'"]')[0],view=document.getElementsByClassName(atag)[0],size=node.getAttribute(ctag),data="",func=()=>{if(data+=msvg[0].outerHTML,(i=node.getAttribute(dtag))==size){escapeHTMLPolicy=trustedTypes.createPolicy("forceInner",{createHTML:e=>e}),document.write(escapeHTMLPolicy.createHTML(data));let e=document.createElement("style");e.textContent="\n @media print {\n body {\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n svg {\n display: block;\n page-break-after: always;\n width: 100%;\n height: auto;\n margin: auto;\n }\n div {\n page-break-after: always;\n }\n }\n ",document.head.appendChild(e),setTimeout((()=>window.print()),1e3)}else view.click(),setTimeout(func,10)};func(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment