Worked great on Firefox! I had a 300 page document so when I ran the script I didn't think it was working but it took about 5-6 mins for it to download. I think for a large document it takes time and attempts. First couple attempts, it only downloaded a portion of the document. I scrolled to the bottom of the document each time. By the 5th attempt, it downloaded all the pages. Thanks for making this instructional!
Its not work, please help me Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11
let jspdf = document.createElement("script"); jspdf.onload = function () { let pdf = new jsPDF("p", "pt", "a4"); // Using "pt" (points) for precise A4 dimensions let elements = document.getElementsByTagName("img"); const scaleFactor = 2; // Increase for higher quality if necessary // A4 page dimensions in points (default units for jsPDF) const pageWidth = 595; const pageHeight = 842; for (let i = 0; i < elements.length; i++) { let img = elements[i]; if (!/^blob:/.test(img.src)) { continue; } // Create a high-resolution canvas let canvasElement = document.createElement("canvas"); let con = canvasElement.getContext("2d"); canvasElement.width = img.width * scaleFactor; canvasElement.height = img.height * scaleFactor; con.scale(scaleFactor, scaleFactor); con.drawImage(img, 0, 0, img.width, img.height); // Convert canvas to high-quality image data let imgData = canvasElement.toDataURL("image/jpeg", 1.0); // Calculate aspect-ratio-preserving dimensions to fit within A4 let widthRatio = pageWidth / (img.width * scaleFactor); let heightRatio = pageHeight / (img.height * scaleFactor); let fitRatio = Math.min(widthRatio, heightRatio); // Scaled dimensions based on fitRatio let displayWidth = img.width * scaleFactor * fitRatio; let displayHeight = img.height * scaleFactor * fitRatio; // Centering the image on the A4 page let xOffset = (pageWidth - displayWidth) / 2; let yOffset = (pageHeight - displayHeight) / 2; // Add the image to the PDF page pdf.addImage(imgData, 'JPEG', xOffset, yOffset, displayWidth, displayHeight); if (i < elements.length - 1) { // Only add a new page if more images remain pdf.addPage(); } } pdf.save("download.pdf"); }; jspdf.src = 'cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js'; document.body.appendChild(jspdf);
It says: VM1229:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11
VM568:21 This document requires 'TrustedScriptURL' assignment. VM568:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11 help
it dosen't work: when I press enter: VM436:21 This document requires 'TrustedScriptURL' assignment. VM436:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11 error not working bro.....
If i go for this process the admin who share the file have download protect would be knowing that i am or that emails try to bypassing through java script. I mean the admin knowing or not know about what we are going to do with file download. If i do this process does my admin will know about this through any notification or security privacy .
With how i used to do it, press the f12 and just search for "videoplayback" on the search bar on the bottom half, then an mp4 file would pop-up. Then that's what you download. Not sure if it still works since I haven't had the need to download a View Only video from gdrives.
VM2575:21 This document requires 'TrustedScriptURL' assignment. (anonymous) @ VM2575:21 VM2575:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11 error not working bro.....
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11 error not working bro.....
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment. at :21:11 error not working bro.....
// Create a trusted types policy to handle the script URL safely let policy = window.trustedTypes ? trustedTypes.createPolicy('default', { createScriptURL: (input) => input }) : { createScriptURL: (input) => input }; // Create a script element for jsPDF let jspdf = document.createElement("script"); jspdf.onload = function () { let pdf = new jsPDF(); let elements = document.getElementsByTagName("img"); for (let i = 0; i < elements.length; i++) { let img = elements[i]; if (!/^blob:/.test(img.src)) { continue; } let canvasElement = document.createElement('canvas'); let con = canvasElement.getContext("2d"); canvasElement.width = img.width; canvasElement.height = img.height; // Draw image onto canvas con.drawImage(img, 0, 0, img.width, img.height); // Convert canvas to image data let imgData = canvasElement.toDataURL("image/jpeg", 1.0);
// Add the image data to the PDF pdf.addImage(imgData, 'JPEG', 0, 0);
// Add a new page if there are more images if (i < elements.length - 1) { pdf.addPage(); } } // Save the PDF pdf.save("download.pdf"); }; // Set the src of the script element using the trusted types policy jspdf.src = policy.createScriptURL('cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js'); // Append the script to the body to load it document.body.appendChild(jspdf);
Worked great on Firefox! I had a 300 page document so when I ran the script I didn't think it was working but it took about 5-6 mins for it to download. I think for a large document it takes time and attempts. First couple attempts, it only downloaded a portion of the document. I scrolled to the bottom of the document each time. By the 5th attempt, it downloaded all the pages. Thanks for making this instructional!
worked on mac/safari. thank you lots. i am preparing for an exam
Agreed with some others, for Firefox, works like a charm. Thanks dude
Thank you so much!!!!!!!!!!!!!! I really wanted to download a music sheet and this saved me!
Its not work, please help me
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
i have this this problem too
this is first time when the first video is enough for something thanks bro you are super cool 😍😍😍😍
doesn't work on Firefox,
On MS EDGE - The script is allowed but at last I got an error saying "TruescriptURL" needed
something like that
Please Help
try in safari or in firefox
omg , thank you, it is working, thank you, it worked with chrome ❤❤❤
For some reason it doesn't work on Chrome but it does work on Firefox. Image quality is somewhat low, can this be improved? Thanks.
let jspdf = document.createElement("script");
jspdf.onload = function () {
let pdf = new jsPDF("p", "pt", "a4"); // Using "pt" (points) for precise A4 dimensions
let elements = document.getElementsByTagName("img");
const scaleFactor = 2; // Increase for higher quality if necessary
// A4 page dimensions in points (default units for jsPDF)
const pageWidth = 595;
const pageHeight = 842;
for (let i = 0; i < elements.length; i++) {
let img = elements[i];
if (!/^blob:/.test(img.src)) {
continue;
}
// Create a high-resolution canvas
let canvasElement = document.createElement("canvas");
let con = canvasElement.getContext("2d");
canvasElement.width = img.width * scaleFactor;
canvasElement.height = img.height * scaleFactor;
con.scale(scaleFactor, scaleFactor);
con.drawImage(img, 0, 0, img.width, img.height);
// Convert canvas to high-quality image data
let imgData = canvasElement.toDataURL("image/jpeg", 1.0);
// Calculate aspect-ratio-preserving dimensions to fit within A4
let widthRatio = pageWidth / (img.width * scaleFactor);
let heightRatio = pageHeight / (img.height * scaleFactor);
let fitRatio = Math.min(widthRatio, heightRatio);
// Scaled dimensions based on fitRatio
let displayWidth = img.width * scaleFactor * fitRatio;
let displayHeight = img.height * scaleFactor * fitRatio;
// Centering the image on the A4 page
let xOffset = (pageWidth - displayWidth) / 2;
let yOffset = (pageHeight - displayHeight) / 2;
// Add the image to the PDF page
pdf.addImage(imgData, 'JPEG', xOffset, yOffset, displayWidth, displayHeight);
if (i < elements.length - 1) { // Only add a new page if more images remain
pdf.addPage();
}
}
pdf.save("download.pdf");
};
jspdf.src = 'cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js';
document.body.appendChild(jspdf);
work well thank you very much!
Its working on Firefox thanks dude🔥🔥
Thank you! worked wonders
thank you brother. your video helped a lot. our teacher is greedy and wont let us download this pdf so its hard to read out side. thank you again
It says: VM1229:21 Uncaught
TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
did you got any solution ??? I am also getting the same error.
@@dashMusic-06 no i didn't😢
use firefox instead of chrome
VERY USE FULL , tHANKS
IT WORKED! THANK YOU SO MUCH
Which browser?
Will the file owner know if I do the hack?
Doesn't work on Chrome. Worked on Safari. Thanks!
Thanksssssss it worked!!!
THANKS BROOOO!!!
VM568:21 This document requires 'TrustedScriptURL' assignment.
VM568:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
help
same lol
Thanks, it saved me 50 buks
Works with Brave browser too
Uncaught syntax error: redeclaration of let jspdf
Thanks a lot it work
what browser do you use?
it dosen't work: when I press enter:
VM436:21 This document requires 'TrustedScriptURL' assignment.
VM436:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
same problem here
You used edge?
@@mahmudtalkssyou used edge?
I use brave. doenst work have the same issue
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
error not working bro.....
did you get a solution
its only downloading the blank page
How to download vides like this ?
THANK U SO MUCH
works perfect on firefox
it worked but many pages were missing
it will not download Orginal quality
If i go for this process the admin who share the file have download protect would be knowing that i am or that emails try to bypassing through java script. I mean the admin knowing or not know about what we are going to do with file download. If i do this process does my admin will know about this through any notification or security privacy .
work perfect on firefox, firt you need typing allow pasting on console :)
for me does not work on opera and chrome.
great, thanks and to disable it again?
how to download videos
With how i used to do it, press the f12 and just search for "videoplayback" on the search bar on the bottom half, then an mp4 file would pop-up. Then that's what you download. Not sure if it still works since I haven't had the need to download a View Only video from gdrives.
It works on Safari. (not with Chrome)
I have the same error
thks brow
it works on firefox
VM2575:21 This document requires 'TrustedScriptURL' assignment.
(anonymous) @ VM2575:21
VM2575:21 Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
i also got same error
same, not working
tambem da esse erro pra mim !!
@@Vv3E google drive updated its security patches i guess. no more loopholes
@@senirukankanamge4455 damn I was just a few months late
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
error not working bro.....
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
error not working bro.....
Uncaught TypeError: Failed to set the 'src' property on 'HTMLScriptElement': This document requires 'TrustedScriptURL' assignment.
at :21:11
error not working bro.....
use safaari browser
// Create a trusted types policy to handle the script URL safely
let policy = window.trustedTypes ? trustedTypes.createPolicy('default', {
createScriptURL: (input) => input
}) : { createScriptURL: (input) => input };
// Create a script element for jsPDF
let jspdf = document.createElement("script");
jspdf.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName("img");
for (let i = 0; i < elements.length; i++) {
let img = elements[i];
if (!/^blob:/.test(img.src)) {
continue;
}
let canvasElement = document.createElement('canvas');
let con = canvasElement.getContext("2d");
canvasElement.width = img.width;
canvasElement.height = img.height;
// Draw image onto canvas
con.drawImage(img, 0, 0, img.width, img.height);
// Convert canvas to image data
let imgData = canvasElement.toDataURL("image/jpeg", 1.0);
// Add the image data to the PDF
pdf.addImage(imgData, 'JPEG', 0, 0);
// Add a new page if there are more images
if (i < elements.length - 1) {
pdf.addPage();
}
}
// Save the PDF
pdf.save("download.pdf");
};
// Set the src of the script element using the trusted types policy
jspdf.src = policy.createScriptURL('cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js');
// Append the script to the body to load it
document.body.appendChild(jspdf);