Comments (2)
Thanks for the question! In theory this might be possible, but I'll first explain a bit about how it's working right now.
When you call the WebViewer constructor that is imported from @pdftron/webviewer
it will create a new iframe element and set the src to be lib/ui/index.html. This HTML file contains script tags for lib/core/CoreControls.js (WebViewer core) and lib/ui/webviewer-ui.min.js (WebViewer UI). Depending on the browser and the type of document that you load, CoreControls will load other files dynamically (e.g. WebAssembly).
Having the HTML, JS and Wasm files available statically makes things simple as we just rely on normal browser requests to load the files. All we need to do it set the src of the iframe and everything will automatically work. We can also make normal JS requests for web workers and other dynamically loaded files.
If we wanted to make it so that you would just need to install @pdftron/webviewer
the simple solution would just be to bundle every single file that might possibly be loaded into a massive JS file including non-JS content. Then at runtime we would extract the HTML data as a string to set the src of the iframe and maybe the JS as well. The extracted JS would then be run in the iframe and it would extract the Wasm to load dynamically. This bundle would be quite large so we'd probably want to split this up so we can lazy load only the modules we need.
To simplify things we'd probably want to get rid of the iframe as well. This comes with its own complications around conflicting CSS, resize events, etc. In theory this should all be possible but it will require more work on our side to investigate.
Note that WebViewer has been around for ~10 years, before npm was widely used in JavaScript projects which is part of the reason why it's structured as it is. We're working on improving the usage with npm and it's good to hear your feedback.
Let me know if you have any other questions!
from webviewer-react-sample.
Sorry for the late reply. It makes more sense now.
Indeed, it would be nice to think of ways to bring this into a friendlier npm environment, but I understand the complications it brings. I guess it's fine to close this.
Thanks for all the explanations.
from webviewer-react-sample.
Related Issues (20)
- why do we have two refs to the webviewer ? HOT 5
- how do we assign a variable value to initialDoc? WebViwer HOT 1
- Redaction annotations created in PDFTron are black-boxed in other viewers HOT 1
- Cant download the pdf in React app after making freeText Annontation HOT 1
- GitHub Pages HOT 17
- GitHub Pages
- Running a local file HOT 4
- About multiple language support for editing pdf text. HOT 1
- network failure when run it on localhost HOT 2
- Sample does not work when npm run build && serve -s build HOT 1
- how to implement Generate DOCX/Word templates with JSON in React JavaScript without a WebViewer HOT 1
- Getting window is not defined HOT 1
- Not able to open large file HOT 4
- Is it possible to disable text selection and text copy from file in WebViewer? HOT 2
- Component re-renders weird when params are added to url HOT 8
- Webviewer is not loading when distribution X-Frame-Options set to DENY HOT 4
- Feature Request: WebViewer - Instance Creator - Iframe on Sharepoint HOT 5
- Typo: The initial doc's value is not capitalized to match the actual file name. HOT 2
- Cannot find how to save cropped area in reactjs PDFTron HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webviewer-react-sample.