mirror of
https://github.com/prasathmani/tinyfilemanager.git
synced 2026-04-26 10:55:56 +03:00
[GH-ISSUE #1132] Offer a local PDF viewer like PDF.js #727
Labels
No labels
Feature
Feature
Is It Really an Issue?
Need More Info
Request
Security
bug
duplicate
enhancement
enhancement
help wanted
invalid
pull-request
question
suggestion
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tinyfilemanager#727
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @logoff on GitHub (Jan 1, 2024).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/1132
Hello.
I use your project behind a secure environment, so my URLs are not publicly available. I would like to have a local preview, not based on Google or Microsoft. For instance, for PDF documents, I recommend implementing a
'local'option using https://github.com/mozilla/pdf.js.Thanks!
@karu73 commented on GitHub (Feb 28, 2024):
this would be much appreciated
@allmycookies commented on GitHub (Feb 11, 2025):
You can render the pdf files with Chrome, Edge and maybe Firefox localy.
Change in the next line of "
if ($is_onlineViewer) {"from:
if ($online_viewer == 'google') { echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px;"></iframe>'; } else if ($online_viewer == 'microsoft') { echo '<iframe src="https://view.officeapps.live.com/op/view.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px;"></iframe>'; } else if ($online_viewer == 'local') { echo '<iframe src="' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px;"></iframe>'; }to (with some height modification):
if ($online_viewer == 'google') { echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height: calc(100vh - 322px);"></iframe>'; } else if ($online_viewer == 'microsoft') { echo '<iframe src="https://view.officeapps.live.com/op/view.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height: calc(100vh - 322px);"></iframe>'; } else if ($online_viewer == 'local') { echo '<iframe src="' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height: calc(100vh - 322px);"></iframe>'; }and in your config you have to set
$online_viewer = 'local';If not working, check your Browser PDF Settings. May set to view pdf in browser, not to download them.
@allmycookies commented on GitHub (Feb 11, 2025):
Or if you want more options download the prebuild pdf.js from
https://mozilla.github.io/pdf.js/getting_started/#downloadunzip it in an folder named pdfjs on the same path as your tfm and add another Line after the last</iframe>'; }:else if ($online_viewer == 'pdfjs') { echo '<iframe src="pdfjs/web/viewer.html?file=' . urlencode(fm_enc($file_url)) . '" frameborder="no" style="width:100%;min-height: calc(100vh - 322px);"></iframe>'; }Some layout modifications
<div class="row"><div class="col-12"><ul class="list-group w-50 my-3" data-bs-theme="<?php echo FM_THEME; ?>">to
<div class="row"><div class="row"><div class="col-12 col-md-4 mt-3"><ul class="list-group w-100 my-3" data-bs-theme="<?php echo FM_THEME; ?>">if ($is_onlineViewer) {fromclass="row mt-3"toclass="col-12 col-md-8 mt-3" an added above another</div>to close the<div class="row">. It should looks like</div></div><div class="col-12 col-md-8 mt-3"><?php if ($is_onlineViewer) {In that case you can change the calc in height from 322px to 90px and the viewer will be next to the meta-info.