Cannot read property 'onLastPageOfBook' of null

34 views
Skip to first unread message

rodolfo tuble

unread,
Jun 4, 2014, 2:04:17 AM6/4/14
to monoc...@googlegroups.com

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

Joseph Pearson

unread,
Jun 4, 2014, 8:11:33 AM6/4/14
to monoc...@googlegroups.com
Your components are loaded into iframes: they must be HTML documents.

— J
--
You received this message because you are subscribed to the Google Groups "Monocle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to monocle-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rodolfo tuble

unread,
Jun 4, 2014, 8:50:07 AM6/4/14
to monoc...@googlegroups.com
What do you mean by that? can you share an example? thank you and terribly sorry for the trouble. 

Joseph Pearson

unread,
Jun 4, 2014, 8:52:44 AM6/4/14
to monoc...@googlegroups.com
I mean that a PDF is not HTML, and Monocle can do nothing with it.

Cheers,

— J

On Wednesday, 4 June 2014, rodolfo tuble <rtc...@gmail.com> wrote:
What do you mean by that? can you share an example? thank you and terribly sorry for the trouble. 

--

rodolfo tuble

unread,
Jun 4, 2014, 8:56:15 AM6/4/14
to monoc...@googlegroups.com
Oh I see, so there is no way for monocle to support PDF. Only Epub and HTML files.

thank you :) 

cam...@libraryforall.org

unread,
Sep 7, 2015, 1:22:13 PM9/7/15
to Monocle
supporting pdfs with monocle is something we created a work-around for by cutting the pdfs into jpgs, which is pretty easy to do, and then applying something like the following:

this.getComponent = function (cmptId) {
      var path = 'file://' + appStorageRoot + this.components[cmptId];
      if(this.layout == "fixed") {
        // For PDF with images  
        return '<p><center><img src="' + path + '"/></center></p>';
      } else {  
        //ePubs
        var ajReq = new XMLHttpRequest();
        ajReq.open("GET", path, false);
        ajReq.send(null);
        return ajReq.responseText;
      }
    };
Reply all
Reply to author
Forward
0 new messages