Spaces:
Sleeping
Sleeping
| <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> |