>
$("#loadLink").click(function() {
let pdfLink = $("#pdfLink").val().trim();
if (pdfLink) {
console.log("Loading PDF from URL:", pdfLink);
loadPDFFromURL(pdfLink);
}
});
async function loadPDFFromURL(pdfLink) {
try {
const response = await fetch(pdfLink);
if (!response.ok) {
throw new Error(`Failed to fetch PDF. Status: ${response.status} ${response.statusText}`);
}
const pdfData = await response.arrayBuffer();
console.log("PDF Data fetched:", pdfData.byteLength, "bytes");
const pdf = await pdfjsLib.getDocument({ data: pdfData }).promise;
renderFlipbook(pdf);
} catch (error) {
console.error("Error loading PDF:", error.message);
}