dealfonso / pdfjs-viewer

A viewer based on PDFjs, which can be embedded in any web page (not using iframes)
Apache License 2.0
48 stars 1 forks source link

Rendering problem #14

Open dfaber2 opened 2 months ago

dfaber2 commented 2 months ago

Carlos: really appreciated pdfs-viewer.js. I have incorporated it into a large project. Had a problem rendering many PDFs that had multiple pages. I changed one line of code and now it renders successfully:

    _setPageContent($page, $content) {
        //$page.find(`.${this.settings.contentClass}`).empty().append($content);
        $page.find(`.${this.settings.contentClass}`).append($content);
    }

I think that there was a race condition where empty() was completing after append() finished, so the image briefly appeared and then was removed. Even when append() runs more than once, it doesn't seem to duplicate the content of the page?

Thanks again for good work. --dfaber@mediyeti.com !Que le vaya bien!

dealfonso commented 2 months ago

Hi,

Thank you for reporting this issue.

I'd like to debug it before adding this patch to the main code because it makes no sense to me that empty ends before append. Under which kind of documents are you getting that problem? Please tell me about the number and type of pages (small images, lots of pictures, big images, text, etc.), and I'll prepare a document to reproduce your problem.

I appreciate your help.

dfaber2 commented 2 months ago

We incorporated your js into our clients instances and immediately got reports of partial display. These initially were incoming faxes or other image documents that were converted to PDF (this did not show up during initial testing with code generated PDF). When I tested on their first fax image it was about 4 pages long, and the last page would display but the others would not. Often only some of the thumbnails would display, and the main images were blank. What interested me was that on some documents during the initial rendering, I would see the real image display very briefly (less than a second) and then the page went blank. Removing the .empty() call completely fixed the problem.

Dan Faber

On Jul 21, 2024, at 1:53 AM, Carlos de Alfonso Laguna @.***> wrote:

Hi,

Thank you for reporting this issue.

I'd like to debug it before adding this patch to the main code because it makes no sense to me that empty ends before append. Under which kind of documents are you getting that problem? Please tell me about the number and type of pages (small images, lots of pictures, big images, text, etc.), and I'll prepare a document to reproduce your problem.

I appreciate your help.

— Reply to this email directly, view it on GitHub https://github.com/dealfonso/pdfjs-viewer/issues/14#issuecomment-2241515698, or unsubscribe https://github.com/notifications/unsubscribe-auth/BKABWW777GFMBPKFXO7VJBDZNNSHVAVCNFSM6AAAAABLGDKBRGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBRGUYTKNRZHA. You are receiving this because you authored the thread.