Created
July 26, 2013 20:28
-
-
Save rjcorwin/6091968 to your computer and use it in GitHub Desktop.
Load a PDF from PouchDB using the PDF.js Viewer. This code would go somewhere around line 2930 in web/viewer.js replacing the code that opens the PDF for Firefox and non B2G browsers. Example (note the parameters): http://test.local:5984/mount/_design/app/PDF-JS-Pouch-Viewer/web/viewer.html?db=testfiles&docId=helloworld&file=helloworld.pdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(params.db && params.docId && params.file) { | |
| Pouch(params.db, function(err, db) { | |
| db.getAttachment(params.docId, params.file, function(err, res) { | |
| var file = window.URL.createObjectURL(res) | |
| //#if (FIREFOX || MOZCENTRAL) | |
| //if (FirefoxCom.requestSync('getLoadingType') == 'passive') { | |
| // PDFView.setTitleUsingUrl(file); | |
| // PDFView.initPassiveLoading(); | |
| // return; | |
| //} | |
| //#endif | |
| //#if !B2G | |
| PDFView.open(file, 0); | |
| //#endif | |
| }) | |
| }) | |
| } | |
| else { | |
| //#if (FIREFOX || MOZCENTRAL) | |
| //if (FirefoxCom.requestSync('getLoadingType') == 'passive') { | |
| // PDFView.setTitleUsingUrl(file); | |
| // PDFView.initPassiveLoading(); | |
| // return; | |
| //} | |
| //#endif | |
| //#if !B2G | |
| PDFView.open(file, 0); | |
| //#endif | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment