How to use pdf.js on desktop/mobile to display a PDF
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to use pdf.js on desktop/mobile to display a PDF
Hi all,
the subject says it all, I downloaded some of the variation of the above mentioned package, but could not make it work.
It even refuses to display the example PDF file included in the package and displays an error that exact that file is missing
with the complete and correct path to that namely file on my machine? I don't get it.
Any hint on what I have to do to make it work highly appreciated!
Thanks!
Best
Klaus
P.S.
The Mac can display PDF in the browser widget right out of hte box, but for Windows we need to include 170 MB (CEF browser stuff)
to our runtimes for the same (simple?) task.
the subject says it all, I downloaded some of the variation of the above mentioned package, but could not make it work.
It even refuses to display the example PDF file included in the package and displays an error that exact that file is missing
with the complete and correct path to that namely file on my machine? I don't get it.
Any hint on what I have to do to make it work highly appreciated!
Thanks!
Best
Klaus
P.S.
The Mac can display PDF in the browser widget right out of hte box, but for Windows we need to include 170 MB (CEF browser stuff)
to our runtimes for the same (simple?) task.
Re: How to use pdf.js on desktop/mobile to disply a PDF
Forgot the URL to the package: https://github.com/mozilla/pdfjs-dist
Re: How to use pdf.js on desktop/mobile to disply a PDF
I know that I will need to copy all these folders and their content to a writable place on the users machine.
But I have no idea what and where to change in which of these files to display a local PDF file.
But I have no idea what and where to change in which of these files to display a local PDF file.
Re: How to use pdf.js on desktop/mobile to disply a PDF
is that the case for the 'pro' PDF feature as well?
(I'll be devling into PDF stuff next month so just asking...)
Re: How to use pdf.js on desktop/mobile to disply a PDF
Also, you may want to look at the opensource XPDFReader : http://www.xpdfreader.com/index.html
I've used it before to very successfully extract text from PDF files - it comes with a 'viewer' for win/linux which may be helpful if you don't need to absolutely embed the PDF. It also lets you export each page as JPG so if you wanted to could do this on the fly i guess to show the PDF as an image instead... it's got a huge number of features which i haven't really looked into so might be worth a look?
S.
I've used it before to very successfully extract text from PDF files - it comes with a 'viewer' for win/linux which may be helpful if you don't need to absolutely embed the PDF. It also lets you export each page as JPG so if you wanted to could do this on the fly i guess to show the PDF as an image instead... it's got a huge number of features which i haven't really looked into so might be worth a look?
S.
Re: How to use pdf.js on desktop/mobile to disply a PDF
Re: How to use pdf.js on desktop/mobile to disply a PDF
Thank you, but this is an external application, I just want to display a PDF file inside of my Livecode app.stam wrote: ↑Tue Apr 12, 2022 10:40 pmAlso, you may want to look at the opensource XPDFReader : http://www.xpdfreader.com/index.html
I've used it before to very successfully extract text from PDF files - it comes with a 'viewer' for win/linux which may be helpful if you don't need to absolutely embed the PDF. It also lets you export each page as JPG so if you wanted to could do this on the fly i guess to show the PDF as an image instead... it's got a huge number of features which i haven't really looked into so might be worth a look?
S.
Since the Windows "default" browser EDGE can display PDF files, I wonder why LC still "sticks" to the CEF stuff.
Maybe it is not as easy to wrap around their web engine as it may be on the Mac, but what do I know?!
Re: How to use pdf.js on desktop/mobile to display a PDF
After some research on the net I found this:
Oh my, what a hassle to simply display a PDF in LC on Windows...
Well that explains why I cannot get it to work locally....
Note: Due to browser security restrictions, PDF.js cannot open local PDFs using a file:// URL.
You will need to start a local web server or upload the files to your web server.
...
Oh my, what a hassle to simply display a PDF in LC on Windows...
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to use pdf.js on desktop/mobile to display a PDF
Does it work outside of LiveCode?Klaus wrote: ↑Wed Apr 13, 2022 11:12 amAfter some research on the net I found this:Well that explains why I cannot get it to work locally....
Note: Due to browser security restrictions, PDF.js cannot open local PDFs using a file:// URL.
You will need to start a local web server or upload the files to your web server.
...
Oh my, what a hassle to simply display a PDF in LC on Windows...
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to use pdf.js on desktop/mobile to display a PDF
No idea, Richard, if it does, it does not help me.
In any case it works online, I've seen many examples of it.
In any case it works online, I've seen many examples of it.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to use pdf.js on desktop/mobile to display a PDF
The https library would let you "serve" the file to the browser widget from the same instance of LC. That lib is also used with Oath, for similar reasons.
Or if it works in other apps you could launch that as a sheet sort of helper app for those files, unless of course you're not just displaying them but also need to do some sort of processing on them.
Or if it works in other apps you could launch that as a sheet sort of helper app for those files, unless of course you're not just displaying them but also need to do some sort of processing on them.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to use pdf.js on desktop/mobile to display a PDF
Ah, yes, thank you, worth to consider!
But I still have no idea where or how to pass the path to the PDF file to whatever file of pdf.js!?
But I still have no idea where or how to pass the path to the PDF file to whatever file of pdf.js!?
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to use pdf.js on desktop/mobile to display a PDF
What does this do on your system?:
Code: Select all
launch url ("file:/path/to/my.pdf")
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to use pdf.js on desktop/mobile to display a PDF
Same as:
I launches "Preview" (macOS) with the PDF.
What are you trying to tell me, Richard?
Code: Select all
launch url ("/path/to/my.pdf")
What are you trying to tell me, Richard?
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to use pdf.js on desktop/mobile to display a PDF
"Or if it works in other apps you could launch that as a sheet sort of helper app for those files, unless of course you're not just displaying them but also need to do some sort of processing on them."
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn