servo / servo

Servo, the embeddable, independent, memory-safe, modular, parallel web rendering engine
https://servo.org
Mozilla Public License 2.0
28.05k stars 3k forks source link

Get pdf.js working in Servo #6098

Open kmcallister opened 9 years ago

kmcallister commented 9 years ago

https://mozilla.github.io/pdf.js/

KiChjang commented 9 years ago

Using the current trunk, the console outputted the following when I clicked on "Demo":

$ ./mach run https://mozilla.github.io/pdf.js/

ERROR:net_traits::image::base: stb_image failed: stbi_load_from_memory failed
PDF 110dd61fd57444010b1ab5ff38782f0f [1.4 pdfeTeX-1.21a / TeX] (PDF.js: 1.1.147)
Warning: Unhandled rejection: TypeError: window.history is undefined
pdfHistoryInitialize@https://mozilla.github.io/pdf.js/web/viewer.js:1466
pdfViewLoad/<@https://mozilla.github.io/pdf.js/web/viewer.js:6372
runHandlers@https://mozilla.github.io/pdf.js/build/pdf.js:1159

Here's the screenshot of what I have:

pdfjs

kmcallister commented 9 years ago

Yeah that's how it looks here as well. I didn't get the console output though (maybe I have it disabled somehow).

You can try my piston-image branch, although it too fails on many images.

jdm commented 9 years ago

5669 is relevant to the console output.

eefriedman commented 8 years ago

Current status: pdf.js assumes window.history exists. If you hack past that, there aren't any errors, the UI renders, and the progress bar works, but it never actually shows the rendered page.

yurydelendik commented 8 years ago

You don't have to block this by window.history or localStorage API -- those are not essential APIs for PDF.js library. The viewer for Servo might look different or not use the same DOM APIs.

The main part of the library is canvas support specifically context 2d. See ctx.xxxx function usages in the https://github.com/mozilla/pdf.js/blob/master/src/display/canvas.js. (And probably @font-face usage with canvas).

Please find more simplified viewer at http://mozilla.github.io/pdf.js/examples/learning/prevnext.html

yurydelendik commented 8 years ago

See also #8917

atouchet commented 4 years ago

I tried testing this out and loading https://mozilla.github.io/pdf.js/web/viewer.html resulted in an error message in Servo.

PDF1

https://mozilla.github.io/pdf.js/es5/web/viewer.html loaded however no content in the PDF was visible.

PDF2

sagudev commented 3 months ago

The first error I get is about missing AbortController, we have PR landed, but sadly it got reverted due to flakiness: https://github.com/servo/servo/pull/31361, but even if I use that PR PDF is note rendered (see last image of previous comment), up-to-date link for legacy pdf.js: https://mozilla.github.io/pdf.js/legacy/web/viewer.html. https://mozilla.github.io/pdf.js/examples/ gives this error:

pdf.mjs:11002:32 Promise.withResolvers is not a function

EDIT: This error happens because examples do not use legacy viewer, this will come in next SM upgrade.

I will try to get the list what we are missing for it to work apart from the two known ones.

msub2 commented 1 week ago

@sagudev Any update on what else might be blocking this (aside from AbortController support)?

sagudev commented 1 week ago

Not really, as I got sidetracked so you can pick it up.