PDF viewer only shows first 50 pages

When viewing a large PDF file using the Seafile web interface only the first 50 pages are displayed. Where is this restriction managed (Seafile, webserver, pdf viewer) an how can it be removed?
I use Seafile CE for Raspberry Pi with nginx on a cubietruck running armbian. Any help is much appriciated.

You have to edit file /seahub/templates/snippets/pdfjs_file_viewer.html. But limitation is there for some reason, so do not blame developer that your browser crash or slow down.

AND you have to edit this file every Seafile server update.

First mention about 50 pages limit start on line 22. It’s only shows message that document is limited.

For edit shoed pages, update line 29. Just change line below to and use number of pages you want var shownPageCount = pdf.numPages < 100 ? pdf.numPages : 100;

1 Like

Thanks for Your reply. @daniel.pan: Any chance to make this behaviour configurable in future versions?

You can change constants 50 to configuration constant for example PDF_PAGES_COUNT

So changes 50 in source code to {{PDF_PAGES_COUNT}} and in settings.py setup default value to 50, then send pull request.

It should be configurable in seahub_settings.py

1 Like

Well, what might sound easy to do for You looks more like a deep dive for me. :slight_smile: I’m not as deep in coding as You are. I’ll try to figure out how to do it this evening. Thanks again for Your detailed explanation.

For make it clear. I’m not Python dev, and not sure that this is working way i’m just guesing and don’t have time to test it or find a way. It’s only looks like it can works.

I’m sure that there should be some input check for configuration value, cause you can type some float typed number or string that may crash server, but maybe seafile devs don’t care about it cause you have to know what you doing, who knows? :smiley:

OK, I’ll investigate further and report here.

This might be a possible work around. I disabled pdf.js via:

USE_PDFJS = False

in seahub_settings.py and added ‘pdf’ to OnlyOffice (OO) running in Subdirectory mode

ONLYOFFICE_FILE_EXTENSION = (‘doc’, ‘docx’, ‘ppt’, ‘pptx’, ‘xls’, ‘xlsx’, ‘odt’, ‘fodt’, ‘odp’, ‘fodp’, ‘ods’, ‘fods’, ‘pdf’)

Long PDFs open in the OO Document Viewer as read-only documents.

5 Likes

Maybe put this into the manual.

2 Likes

Good idea! Thanks for the hint.

Since version 6.3.1 this isn’t working. Any solutions? Or do I have to make a pull request?

I can confirm the problem in CE 6.3.1 under Ubuntu 16.04.

It looks like ‘USE_PDFJS = False’ in seahub_settings.py is being ignored. I can see ‘type=“text/javascript” src="/media/js/pdf.js"’ being executed in the Web console in Firefox.

There is an associated error in Firefox:

Source map error: request failed with status 404
Resource URL: https://sf.mydomain.com/media/assets/css/bootstrap.min.b00faad199b5.css
Source Map URL: bootstrap.min.css.map[Learn More]

Chromium Javacript console shows:

pdf.js:6211 The provided value ‘moz-chunked-arraybuffer’ is not a valid enum value of type XMLHttpRequestResponseType.
supportsMozChunkedClosure @ pdf.js:6211

Are these related in any way?

Looks like this is not fixed in CE 6.3.2. Is this a bona fide bug? Can we get someone in development to confirm or deny (@daniel.pan)? -Thanks

It will be fixed in a future release.

1 Like

I created a pdfjs_file_viewer.html in my seahub-data/custom folder, I commented out the 50 page warning and modified the code from:
var shownPageCount = pdf.numPages < 50 ? pdf.numPages : 50;
to:
shownPageCount = pdf.numPages;

Then I created a simple script to backup the original pdfjs_file_viewer.html file and replace it with a symlink to my modified version. Then I just run the script every time I update.

Code for the script is as follows:

#!/bin/sh
cd /home/pi/haiwen/seafile-server-latest/seahub/seahub/templates/snippets
mkdir backup
mv pdfjs_file_viewer.html backup
ln -s /home/pi/haiwen/seahub-data/custom/scripts/pdfjs_file_viewer.html pdfjs_file_viewer.html
4 Likes

Looks like no change in CE 6.3.3. Can someone confirm or deny?

1 Like

I confirm, version CE 6.3.4 bug is not fixed.

1 Like

https://manual.seafile.com/config/seafevents-conf.html

But this is only for the professional version.

My biggest concern is that ‘USE_PDFJS = False’ in seahub_settings.py is still being ignored (CE 6.3.4). I’d like to see that fixed so that the OO workaround works again.

I did find another workaround, however. If I go to my Seafile server using a web browser using WebDAV (https://sf.mydomain.com/seafdav in my case) I can login and access long PDF documents in the browser.

2 Likes