mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.34k stars 9.97k forks source link

PDF Slow to load, slow to render, page count wrong #11025

Closed blackmambahk closed 5 years ago

blackmambahk commented 5 years ago

Attach (recommended test (2).pdf ) or Link to PDF file here:

The attached PDF loads very slowly and then renders very slowly and PDFJS for some reason thinks there are 15 pages, but displays pages 10-15, the actual PDF has only 6 pages. Problem exist in latest Firefox as well as in out app using latest PDFJS on chrome and firefox. Chromes native PDF renderer loads much faster though it does appear very jerky when scrolling.

Is there something about this PDF that we could tell the client to change that would fix the issue?

Snuffleupagus commented 5 years ago

Attach (recommended test (2).pdf ) or Link to PDF file here:

With the exception of the PDF file, this issue is missing all of the other information as requested in https://github.com/mozilla/pdf.js/blob/master/.github/ISSUE_TEMPLATE.md

The attached PDF loads very slowly and then renders very slowly

Please note that the PDF file is 4.77 MB in size, which isn't exactly small for a document with only six pages. However, the PDF file loads quickly in the default viewer and "slowly" is highly subjective, so without actual number this part isn't really actionable. As for the "renders slowly" part, again numbers are needed here, the PDF file contains fairly large images (probably unnecessarily large for web usage) which would explain why rendering doesn't feel instantaneous (taking between 2-4 seconds/page for me).

[...] PDFJS for some reason thinks there are 15 pages, but displays pages 10-15, the actual PDF has only 6 pages.

The PDF file consists of six pages, which displays as expected in all viewers I've tried including PDF.js. Please explain what you actually mean here, preferable with screen-shots (as asked for in the ISSUE_TEMPLATE), since it's quite difficult to understand the above as-is.

blackmambahk commented 5 years ago

TestScreenshote Screenshot from FireFox 68.0.1 64Bit WIndows 10.

Shows in top left the page number as 15 and next to it says (6 of 6 ) if you scroll upwards to the firts page it will show the page number as 10 and next to it (1 of 6). Hence my comment PDFJS thinks there are 15 pages but display from page 10 to 15 . The original document has only 6 pages as its notes (6 of 6) .

blackmambahk commented 5 years ago

As to the slow comment, it was sent by a client who thought it was slow, it was viewed by several colleagues who thought it was slow before being passed to me and I thought it was slow.

I have a PC with 32GB of memory and an i7 CPU maybe not the fastest but still fairly quick I think...

After loading the first time I scroll down to the last page of the PDF I am staring at a blank screen for over 7s.

Thats not what we normally see with PDFs... so everyone so far has agreed with the client it is slow..

Snuffleupagus commented 5 years ago

Hence my comment PDFJS thinks there are 15 pages but display from page 10 to 15 .

There's nothing wrong here since those are Page Labels which are specified by the PDF file itself, and the same behaviour can be reproduced in e.g. Adobe Reader as well; please refer to the relevant part of the PDF specification: https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1696265


Furthermore, you still have updated the initial post with all of the information requested in https://github.com/mozilla/pdf.js/blob/master/.github/ISSUE_TEMPLATE.md, which is necessary in order for an issue to be valid.

blackmambahk commented 5 years ago

Web browser and its version: FireFox 68.0.1 Chrome 75.0.3770.142 (Official Build) (64-bit) Operating system and its version: WIndows 10 version 1809 PDF.js version: In our app we use 2.2.228, in FireFOx it is what version is in 68.0.1 Is a browser extension:

Steps to reproduce the problem: 1. 2. Load PDF and scroll to bottom

What is the expected behavior? (add screenshot). It would render quicker.

What went wrong? (add screenshot).Nothing went wrong it was just slow to load and render

blackmambahk commented 5 years ago

Well if you say there is nothing wrong we will just go back to the client and tell him there is nothing wrong it is expected to perform like that

Snuffleupagus commented 5 years ago

Well if you say there is nothing wrong we will just go back to the client and tell him there is nothing wrong it is expected to perform like that

I've said nothing of the sort, please don't misconstrue me here!

What I've however said, is that until https://github.com/mozilla/pdf.js/issues/11025#issuecomment-516817216 and https://github.com/mozilla/pdf.js/issues/11025#issuecomment-516819351 was posted, this issue was missing crucial information needed for it to be actionable.

One way to immediately improve performance of this PDF file could perhaps be to see if https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#optimize helps.