Spaces:
Sleeping
Sleeping
File size: 2,040 Bytes
39301a8 1b6544e 39301a8 a8c6dd8 06369f2 3aa61c1 a8c6dd8 39301a8 a8c6dd8 6aef526 39301a8 84a2268 39301a8 a8c6dd8 39301a8 a8c6dd8 39301a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF NBS Search - ADR MVP.1</title>
</head>
<body>
hi
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.14.305/pdf.min.js"></script>
<script >
///////////////////////////////////////////////BEGIN JS CODE//////////////////////////////////////////////////
// Function to send the Dropbox link and keyword to the server
function getURLParams() {
const urlParams = new URLSearchParams(window.location.search);
return {
pdfLink: urlParams.get('pdfLink'),
keyword: JSON.parse(decodeURIComponent(urlParams.get('keyword') || "[]")), // Decode and parse
pageNumber: parseInt(urlParams.get('page')) || 1,
zoomRect: urlParams.get('zoom') // Expecting format: "x,y,width,height"
};
}
function processPdf() {
// const pdfLink = 'https://www.dropbox.com/scl/fi/hnp4mqigb51a5kp89kgfa/00801-ARC-20-ZZ-S-A-0002.pdf?rlkey=45abeoebzqw4qwnslnei6dkd6&st=m4yrcjm2&dl=1'; // Dropbox link
// const keyword = ['115 INTEGRATED MRI ROOM LININGS','710 TRANSPORTATION'] ; // Example keyword
const { pdfLink, keyword, pageNumber, zoomRect } = getURLParams();
// Create a new FormData object to send the data as form data
const formData = new FormData();
formData.append('pdf_link', pdfLink);
formData.append('keyword', JSON.stringify(keyword));
console.log('ay haga pleaseee')
// Send the data to the Flask server
fetch('/apiNBSData', {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
if (data.download_link) {
window.location.href = data.download_link; // This will use the rect info from Flask
} else {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
});
}
// Call the function to process the PDF
processPdf();
</script> |