Re:Implementing form filling and accessibility in the Firefo...
by rectang on Friday October 15, 2021 @06:23PM
(#28883828)
I recently had to implement a custom PDF viewer using PDF.js. It took a loooong time, because PDF.js is so confusing to work with. We went way over what we thought was a conservative time estimate. :(
It's not just a matter of documentation, but API design. Beyond the bare minimum functionality, you'll need bits and pieces of semi-public API.
For example, if you want to use the "text layer" (for selectable text) you'll need a CSS file which is inside the `web/` directory. But what's in `web/` is incomplete and not officially supported.
Re:Implementing form filling and accessibility in the Firefo...
by iapark on Friday October 15, 2021 @07:03PM
(#28884145)
I wish there were better wrappers for it too. One of the projects I'm still quite proud of that I made as a student was a react wrapper around PDF.js used here https://boardbook.kent.edu/ (though since they no longer seem to be using it I guess it will probably go dead at some point), but the fact there wasn't really a good open source one and as you say the docs were pretty lacking. My favorite discovery was that the performance was much worse unless I registered a particular scroll listener. It's been years now so I only vaguely remember, but I think registering a listener for `wheel` would cause scroll events to be treated as blocking and this made the whole scrolling experience less janky.
Re:Implementing form filling and accessibility in the Firefo...
by lucideer on Saturday October 16, 2021 @01:15AM
(#28885726)
> And how they have a solution called quickjs. _no_ documentation whatsoever about how to use it.
This isn't an excuse for the lack of docs for pdfjs itself, but fwiw quickjs is a 3rd-party project that's documented here https://bellard.org/quickjs/quickjs.html
Re:Implementing form filling and accessibility in the Firefo...
by spankalee on Friday October 15, 2021 @08:49PM
(#28884701)
This reminds me that I should finish off my <pdf-viewer> event based on PDF.js with the goal of just being able to drop an easily customizable viewer into any page:
https://github.com/justinfagnani/pdf-viewer-element
On the docs front, I couldn't agree more. It's tough to use.
Re:Implementing form filling and accessibility in the Firefo...
by gizdan on Saturday October 16, 2021 @02:25AM
(#28885945)
A while ago I tried parsing my payslips with PDF.js. It took me way too long to figure out the API calls needed. There were a few examples and that's it.
Re:Implementing form filling and accessibility in the Firefo...
by gervwyk on Friday October 15, 2021 @05:43PM
(#28883472)
Shameless plug. I recently wrote an article for Lowdefy (co-founder here) for using pdfMake with Lowdefy to generate pdfs. Works really great and easy, perhaps the next step is to add a pdf render block using pdfJs.
See the article: https://docs.lowdefy.com/generate-pdf-document-from-data
(edit: confused pdfJs for jsPdf)
But PDFJS folks, how can you do such a subpar job at documentation?
There is really no documentation available on pdfjs. Or a proper changelog. Like in this article they talk about JS execution in pdfjs. And how they have a solution called quickjs. _no_ documentation whatsoever about how to use it.
This has been their documentation for years:
https://mozilla.github.io/pdf.js/api/
Had I created something as complex and magnificent as pdfjs I would've documented _the hell_ out of it.
I get that pdfjs usage in normal web is not their priority and what they care about is the Firefox pdf viewer but I'm sure they would've had a much better contribution rate had they done better api docs.