javascript - PDFObject library: catching error - or how to know when my PDFObject is empty -
i have question use pdfobject library. (http://pdfobject.com/) (i use angularjs in front end)
//this html code: <div id="boxpdf"></div> //here code in controller var pdfurl = '/myurl/myrestservice/'+iddocument; var mypdf = new pdfobject({ url: pdfurl, pdfopenparams: { width: "100%", height: "1500" }, id: 'myidobject' }); mypdf.embed('boxpdf');
the code works, annoying thing if send backend empty pdf, library anyway shows gray box. i'd catch exeption , don't show gray box example. how can mypdf , understand if full or empty? attention , sorry bad english, igor
sorry, not possible use javascript determine whether pdf has loaded.
with flash, can determine whether swf loaded because flash player provides api include percentloaded property. enables developers query load status of swf.
pdfs not have unified 'player', typically loaded either browser's default pdf rendering engine (usually proprietary), adobe reader, or adobe competitor foxit reader. these pdf rendering systems have different capabilities. have not standardized on particular feature set or javascript api, therefore there no standard way check whether pdf has loaded.
pdfobject designed provide fallbacks in case browser doesn't support pdf embedding. cannot verify whether pdf url legitimate or not -- pdfobject create <object>
in markup, src
pointing url. cannot verify whether url points pdf or other file type. if invoke pdfobject , browser support pdf embedding, <object>
whether url legitimate or not.
Comments
Post a Comment