viewer.js icon indicating copy to clipboard operation
viewer.js copied to clipboard

Insert advertisement banner between pages

Open devphp90 opened this issue 11 years ago • 5 comments

Hi all,

I want to add some image banners for advertising. Example:

  • page 3
  • banner ads
  • page 4

How can I do that.

I have read the document but no idea to custom.

Regards

devphp90 avatar Jul 12 '14 14:07 devphp90

You could do this in the presentation layout by listening for pagefocus events and when you get to page 4, hide the document and show an ad until the user clicks "next" or something (then show the document and page 4).

For example:

var lastPage;
viewer.on('pagefocus', function (event) {
    if (event.data.page === 4 && lastPage === 3) {
        //hide viewer, show ad
    }
    lastPage = event.data.page;
});

There's not really a simple way to do this (yet) for scrollable layouts. You could write your own layout that does this, but it would not be trivial to implement. I have been toying around with some ideas on how to do page manipulation (adding/removing/reordering, etc) as a first-class API on the viewer, but haven't had a chance to implement anything like that yet.

lakenen avatar Jul 12 '14 15:07 lakenen

Hi Lakenen, thank for your response, let me try that.

Regards,

devphp90 avatar Jul 12 '14 16:07 devphp90

how can i start to edit my own layout please ? it mean, what exactly file i have to edit ? thank you

esoftcard avatar Jul 12 '14 16:07 esoftcard

There's not yet very good documentation on how each of the built-in modes works, but you can find some examples if you look at the other layout modes section. Otherwise, you might want to check out the built in layouts (src/js/components/layout*).

lakenen avatar Jul 12 '14 16:07 lakenen

I found this : src/js/component/view-base.js

should i add a add ads function here link : function ads() { }

esoftcard avatar Jul 13 '14 02:07 esoftcard