1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2025-01-05 02:06:03 +00:00

Display PDF documents inline on supported devices

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-12-26 15:49:51 +01:00
parent 9435cb1324
commit 8c9dc8d307
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E
2 changed files with 28 additions and 2 deletions

View file

@ -12,7 +12,7 @@
</div>
</nav>
<div class="container mt-4">
<div class="container my-4">
<div class="row">
<div class="col">
<div
@ -36,6 +36,19 @@
</div>
</div>
<div
v-else-if="fileType.startsWith('application/pdf') && canViewPDF"
class="card position-relative"
style="padding-top: calc(297/210*100%);"
>
<div class="card-body text-center">
<iframe
class="h-100 position-absolute start-0 top-0 w-100"
:src="path"
/>
</div>
</div>
<div
v-else-if="fileType.startsWith('image/')"
class="card"
@ -125,6 +138,19 @@ const rewrites = {
}
export default defineComponent({
computed: {
canViewPDF(): boolean {
/*
* iOS reports they can display PDFs but they'll display only
* the first page without any means of navigation, therefore we
* disable PDF viewing on iOS
*/
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1
return navigator.pdfViewerEnabled && !isIOS
},
},
data() {
return {
error: null,

View file

@ -20,4 +20,4 @@
"vue": "^3.5.13",
"vue-i18n": "^9.14.2"
}
}
}