Skip to content

Commit

Permalink
Fix path to image resources
Browse files Browse the repository at this point in the history
When "./js/pdfjs/web/images/" is resolved and pretty URLs are enabled

the result is "{SERVER}/apps/files_pdfviewer/js/pdfjs/web/images/",

which works as expected. However, if pretty URLs are not enabled the

absolute path becomes

"{SERVER}/index.php/apps/files_pdfviewer/js/pdfjs/web/images/" instead.

As the images are static files they are not served by "index.php", so

they can not be found and therefore are not rendered in the PDF.

To solve that now the path is generated in PHP and provided through the

template, similarly to how it is done, for example, for the path to the

cmap files.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>

Signed-off-by: nextcloud-command <[email protected]>

[skip ci]
  • Loading branch information
danxuliu authored and backportbot[bot] committed Jan 16, 2025
1 parent 4a85f2b commit 33daf1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/workersrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function initializeCustomPDFViewerApplication() {
PDFViewerApplicationOptions.set('cMapUrl', head.getAttribute('data-cmapurl'))
PDFViewerApplicationOptions.set('sandboxBundleSrc', head.getAttribute('data-sandbox'))
PDFViewerApplicationOptions.set('enablePermissions', true)
PDFViewerApplicationOptions.set('imageResourcesPath', './js/pdfjs/web/images/')
PDFViewerApplicationOptions.set('imageResourcesPath', head.getAttribute('data-imageresourcespath'))
PDFViewerApplicationOptions.set('enableScripting', head.getAttribute('data-enableScripting') === true)

if (hideDownload === '1') {
Expand Down
3 changes: 2 additions & 1 deletion templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<head data-workersrc="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/build/pdf.worker.js')) ?>?v=<?php p($version) ?>"
data-enableScripting="<?php p($enableScripting ? true : false) ?>"
data-sandbox="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/build/pdf.sandbox.js'))?>"
data-cmapurl="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/cmaps/')) ?>">
data-cmapurl="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/cmaps/')) ?>"
data-imageresourcespath="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/images/')) ?>">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
Expand Down

0 comments on commit 33daf1a

Please sign in to comment.