Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Created July 26, 2013 20:28
Show Gist options
  • Select an option

  • Save rjcorwin/6091968 to your computer and use it in GitHub Desktop.

Select an option

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
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