joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Cannot read property 'onLastPageOfBook' of null on using PDF file #249

Open rebbieboi opened 9 years ago

rebbieboi commented 9 years ago

I am new to monocle and was asked to use your api for reading PDF, EPUB and HTML ebooks, So far I have succeeded in Epub and HTML. but for PDF i get that error above.

I use this code:

var bookData = { getComponents: function () { return [ '1.pdf' ]; }, getContents: function () { return [ {title: "1", src: '1.pdf'} ] }, getComponent: function (componentId) { return {url:componentId}; }, getMetaData: function(key) { return { title: "Test documents", creator: "Aron Woost" }[key]; } }

        Monocle.Events.listen(
            window,
            'load',
            function () {
                window.reader = Monocle.Reader('reader', bookData);
            }
        );  

What am i doing wrong here?

Thank you

AbhilashThomas commented 9 years ago

Hi, I don't think this would work as you are just passing the 1.pdf for the iframe URL which may be then rendered by the browser using the embed tag, atleast on chrome, instead of any actual HTML. If you can extract the PDF text and then pass it, you may have success.But then you may loose formatting and all that... Apart from the error , what do you see in the monocle container?