Comments (5)
Try this code, then use GeneratePDF.cmd
from google-drive-pdf-downloader.
Try this code, then use GeneratePDF.cmd
Thank you!
from google-drive-pdf-downloader.
Hi, the pastebin doesn't work anymore. Is there any other workarounds for this?
from google-drive-pdf-downloader.
Hi, the pastebin doesn't work anymore. Is there any other workarounds for this?
let pdfDocumentName = "Document";
function generatePDF_DataFile() {
let doc = ""; // Dichiarazione locale di doc all'interno della funzione
let imgTags = document.getElementsByTagName("img");
let checkURLString = "blob:https://drive.google.com/";
let validImgTagCounter = 0;
for (let i = 0; i < imgTags.length; i++) {
if (imgTags[i].src.substring(0, checkURLString.length) === checkURLString) {
validImgTagCounter = validImgTagCounter + 1;
let img = imgTags[i];
let canvas = document.createElement('canvas');
let context = canvas.getContext("2d");
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
context.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight);
let imgDataURL = canvas.toDataURL();
if (doc === "") {
doc = imgDataURL;
} else {
doc = doc + "\n" + imgDataURL;
}
}
}
let anchorElement = document.createElement("a");
let file = new Blob([doc], { type: 'text/plain' });
url = URL.createObjectURL(file);
anchorElement.href = url;
anchorElement.download = pdfDocumentName + ".PDF_DataFile";
document.body.appendChild(anchorElement);
anchorElement.click();
}
let allElements = document.querySelectorAll("*");
let chosenElement;
let heightOfScrollableElement = 0;
for (let i = 0; i < allElements.length; i++) {
if (allElements[i].scrollHeight >= allElements[i].clientHeight) {
if (heightOfScrollableElement < allElements[i].scrollHeight) {
chosenElement = allElements[i];
heightOfScrollableElement = allElements[i].scrollHeight;
}
}
}
if (chosenElement.scrollHeight > chosenElement.clientHeight) {
console.log("Auto Scroll");
let scrollDistance = Math.round(chosenElement.clientHeight / 2);
let loopCounter = 0;
function myLoop(remainingHeightToScroll, scrollToLocation) {
loopCounter = loopCounter + 1;
console.log(loopCounter);
setTimeout(function() {
if (remainingHeightToScroll === 0) {
scrollToLocation = scrollDistance;
chosenElement.scrollTo(0, scrollToLocation);
remainingHeightToScroll = chosenElement.scrollHeight - scrollDistance;
} else {
scrollToLocation = scrollToLocation + scrollDistance;
chosenElement.scrollTo(0, scrollToLocation);
remainingHeightToScroll = remainingHeightToScroll - scrollDistance;
}
if (remainingHeightToScroll >= chosenElement.clientHeight) {
myLoop(remainingHeightToScroll, scrollToLocation);
} else {
setTimeout(function() {
generatePDF_DataFile();
}, 1500);
}
}, 400);
}
myLoop(0, 0);
} else {
console.log("No Scroll");
setTimeout(function() {
generatePDF_DataFile();
}, 1500);
}
This doesn't work?
from google-drive-pdf-downloader.
Yooo, thanks man. The code works. It was just that the pastebin link didn't work. Thank you again man, you doin' god's work.
from google-drive-pdf-downloader.
Related Issues (19)
- Does not work HOT 7
- Compiling go HOT 6
- error Access is denied.
- Improving Quality HOT 1
- Pull request for nodejs script
- it's slower than old method, try increase scroll speed
- Error: Uncaught SyntaxError: Identifier 'doc' has already been declared HOT 9
- UnableToOpenBlob?
- please delete
- Have you used this for sharepoint pdfs that are readonly?
- Error on Method 1 HOT 1
- Page limit using method 1
- invalid png base64 file HOT 1
- Method1 works on Mac with Chrome. How to convert to PDF HOT 2
- all is great until it downloads HOT 1
- Facing issue in Conversion HOT 2
- It work great for 3 pdf then it suddenly stop working at 70-80%
- [Feature Request] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-drive-pdf-downloader.