Comments (7)
Now that PDFObject uses iframes exclusively, the onload handler will be consistent across browsers.
Important: The onload event only indicates that the iframe has loaded something, there is no guarantee the iframe has properly loaded the PDF (and no way to check).
let pdf_iframe = PDFObject.embed("myfile.pdf");
pdf_iframe.addEventListener('load', function () {
alert('loaded');
});
from pdfobject.
A good idea, but I don't think this is possible; Adobe Reader exposes a JavaScript API, but built-in PDF readers (Chrome, Safari) don't expose a JavaScript API. No API means no way to know whether the file has finished loading. Sorry.
from pdfobject.
Would pre-loading the pdf be a possibility? I suppose that could allow to know when it finishes loading.
from pdfobject.
ist there now 4 years later the possibility to get a load event?
from pdfobject.
This is not possible due to a limitation in the browsers themselves -- their built-in PDF rendering engines do not provide APIs. There is no 'loaded' event, and no way to know whether the PDF has properly loaded.
from pdfobject.
I'm not sure if this changed recently, but it looks to be possible to add a load
event listener to either the iframe (PDFObject 2.x) or object (PDFObject 1.x) as follows:
v1.2.0
PDFObject({ url: '/test.pdf' }).embed(document.querySelector('#pdf'));
document.querySelector('#pdf object').addEventListener('load', function () {
alert('loaded');
});
v2.3.0
PDFObject.embed('/test.pdf', '#pdf');
document.querySelector('#pdf iframe').addEventListener('load', function () {
alert('loaded');
});
I am currently using this to implement a loadmask/spinner.
from pdfobject.
I added this use case to the docs https://pdfobject.com/examples/#callback-on-onload-event
from pdfobject.
Related Issues (20)
- Eraser HOT 1
- PDFObject save button option HOT 1
- Disabled download and print button HOT 1
- Use google docs PDF conversion for mobile devices? HOT 5
- [Documentation] Standalone examples of .html files + PDFObject? HOT 3
- Remove some buttons and only show one page at a time HOT 1
- Render html elements within "the full-browser embed" HOT 1
- Fails to load in IE11 HOT 8
- Is there a way to track button clicks? HOT 2
- Navigator.pdfViewerEnabled support? HOT 8
- PDFObject: Page option not working in Microsoft Edge HOT 2
- The problem occurred when using PDFObject in React: Page A embedded with duplicate Page A. HOT 3
- Cannot set properties of undefined HOT 1
- Prevent download pdf automatically HOT 1
- PDFObject is vulnerable to PDFInjection HOT 4
- XSS in fallback link if url is controllable by attacker HOT 5
- base64 PDF how to set title? HOT 1
- Sign PDF with digital certificate HOT 1
- change default download file name HOT 1
- Automatic download for mobile browsers in full-browser embed 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 pdfobject.