As I needed a PDF parser not relying on PDFKit, I have been using for quite a long time some python scripts in Editorial or Pythonista. But with the COVID19, I have been playing more with javascript. I have developed a version of PDFJS running (offline) in a Scriptable WebView. It is much quicker my previous solution in python (to my surprise).
It is already usable as long as I pass the pdf file in a base64 string or as a remote http url, BUT as soon as I try to pass a local url, it spins forever.
I have tested Scriptable in many ways, it does work in loading local relatives contents but still, it does not work for my little library. If anyone wants to help, I have a gist scriptable-pdfjs-demo to play with. The “library” is at scriptable-pdfjs.
The only glitch I found, but I don’t think it’s related, is that the request.url shown in the WebView.shouldAllowRequest is displaying an extra slash:
file:///private/var/mobile/Library/Mobile%20Documents/iCloud~dk~simonbs~Scriptable//Documents/test2.html
Look for the double slash after Scriptable.
And I also ping @simonbs as he was kind enough to answer my topic: does the response for local request implements a kind of ReadableStream ? (I saw in the docs that pdfjs seems to use this).
Thank you for reading!