Spaces:
Running
Running
Commit ·
9bb9203
1
Parent(s): e31557b
Use embed for PDF preview in DocumentVault
Browse files- js/main.js +16 -1
js/main.js
CHANGED
|
@@ -552,7 +552,22 @@ class App {
|
|
| 552 |
|
| 553 |
const pdfBlob = await response.blob();
|
| 554 |
this.currentPreviewObjectUrl = URL.createObjectURL(pdfBlob);
|
| 555 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
} catch (err) {
|
| 557 |
body.innerHTML = this.previewFallback(
|
| 558 |
file.name,
|
|
|
|
| 552 |
|
| 553 |
const pdfBlob = await response.blob();
|
| 554 |
this.currentPreviewObjectUrl = URL.createObjectURL(pdfBlob);
|
| 555 |
+
const googleViewerUrl = `https://docs.google.com/gview?url=${encodeURIComponent(`${url}?download=true`)}&embedded=true`;
|
| 556 |
+
body.innerHTML = `
|
| 557 |
+
<div class="preview-pdf-wrap" style="width:100%; height:100%; display:flex; flex-direction:column;">
|
| 558 |
+
<embed
|
| 559 |
+
src="${this.currentPreviewObjectUrl}"
|
| 560 |
+
type="application/pdf"
|
| 561 |
+
width="100%"
|
| 562 |
+
height="100%"
|
| 563 |
+
style="flex:1; border:0;"
|
| 564 |
+
/>
|
| 565 |
+
<div style="padding:12px 16px; border-top:1px solid rgba(0,0,0,0.06); display:flex; justify-content:flex-end;">
|
| 566 |
+
<a href="${googleViewerUrl}" target="_blank" rel="noopener noreferrer" class="btn-secondary" style="text-decoration:none;">
|
| 567 |
+
Open in Google Viewer
|
| 568 |
+
</a>
|
| 569 |
+
</div>
|
| 570 |
+
</div>`;
|
| 571 |
} catch (err) {
|
| 572 |
body.innerHTML = this.previewFallback(
|
| 573 |
file.name,
|