Pdf.js: Easy way to add new menus

Created on 9 Dec 2013  路  8Comments  路  Source: mozilla/pdf.js

I am using PDFJS for a project to view pdfs on the browser. I am using the standard view.html file to view pdfs.

I wanted to add a new menu on the toolbar for emailing reports. I found it complicated to go through the code and see where i should put my menu icon and javascript handler when the menu is clicked. Doesn't look so easy. Any suggestions?

It should be as easy as writhing
secndaryToolbar.addMenu (
{
Icon: ''email.png',
onClick: function() {
alert('email clicked');
}
}
)

Most helpful comment

I don't really think that the standard viewer was created with that kind of expandability in mind.
(Since adding new functionality to the viewer has to go through a thorough review process, I don't know if it should be that easy to add buttons to the standard PDF viewer that is shipped in Firefox.)

The way that you go about adding a button to the secondary toolbar would be something along these lines (using one of the rotation buttons as example):

EDIT: After you have added the HTML and CSS code, you could add the event handling code anywhere you want really. You don't _need_ to do it exactly as I've outlined above, but I've just tried to describe how it's done for the standard buttons.

Hope this helps!

All 8 comments

I don't really think that the standard viewer was created with that kind of expandability in mind.
(Since adding new functionality to the viewer has to go through a thorough review process, I don't know if it should be that easy to add buttons to the standard PDF viewer that is shipped in Firefox.)

The way that you go about adding a button to the secondary toolbar would be something along these lines (using one of the rotation buttons as example):

EDIT: After you have added the HTML and CSS code, you could add the event handling code anywhere you want really. You don't _need_ to do it exactly as I've outlined above, but I've just tried to describe how it's done for the standard buttons.

Hope this helps!

Thank you so much!

Badly needed that. Haven't tested it much but it shows up on mobile and desktop and the event triggers. Excellent.

Ya so i will be watching this project , it has only been 2 weeks and there is so much update already haha.

Closing as answered.

MurWade will you please add step by step code for adding button?

sure man. email me [email protected]

Hi @MurWade can you please email me the guide for adding button? [email protected] thanks

Hi @waisan .

Hey man read @Snuffleupagus comment. It should be pretty clear. I did this a while back

Hi, please can you help me out I am trying to handle this event outside of the pdf.js library, is this plausible?
Many thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timvandermeij picture timvandermeij  路  4Comments

anggikolo11 picture anggikolo11  路  3Comments

kleins05 picture kleins05  路  3Comments

liuzhen2008 picture liuzhen2008  路  4Comments

brandonros picture brandonros  路  3Comments