Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FWD: Write Specific event for pdf pages render using PDF.js

168 views
Skip to first unread message

Brendan Dahl

unread,
Jul 9, 2012, 12:15:12 PM7/9/12
to dev-p...@lists.mozilla.org
Resending this message as it was accidentally discarded:

Hello Everyone,
I have a scenario where I been asked to make online PDF viewer and on viewing mode the user would select certain area of the PDF and upon selection the marked area boundary w.r.s.t pdf should sent to the server.

example If the User click a area of say created at date the boundary of the selected area should be sent to the server

Now I googling around I found that Pdf.js can handle the rendering of pdf in browser but can there be by any chance can I associate the event with the PDF pages as I mention below or should I look for some other solution like flash

I hoping will get and answer for this is pdf.js group

Regards
Viren

Julian Viereck

unread,
Jul 9, 2012, 3:44:59 PM7/9/12
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, vire...@idyllic-software.com
Hi Viren,

> example If the User click a area of say created at date the boundary of the selected area should be sent to the server
>
> Now I googling around I found that Pdf.js can handle the rendering of pdf in browser but can there be by any chance can I associate the event with the PDF pages as I mention below or should I look for some other solution like flash
>
> I hoping will get and answer for this is pdf.js group

The PDF's pages are rendered each onto one HTML5 canvas element. For each of these canvas elements, you can add an event to listen for "click" events or such. That way, you can detect clicks on each individual PDF page and do something with it.

In your case, you might want to listen for the "mousedown" event to get the starting position of the click and then for the "mouseup" event to get the end position. With these two positions, you can draw a rect.

Best,

Julian

PS: Please don't use flash!

Julian Viereck

unread,
Jul 9, 2012, 3:44:59 PM7/9/12
to mozilla-d...@lists.mozilla.org, dev-p...@lists.mozilla.org, vire...@idyllic-software.com
Hi Viren,

> example If the User click a area of say created at date the boundary of the selected area should be sent to the server
>
> Now I googling around I found that Pdf.js can handle the rendering of pdf in browser but can there be by any chance can I associate the event with the PDF pages as I mention below or should I look for some other solution like flash
>
> I hoping will get and answer for this is pdf.js group

The PDF's pages are rendered each onto one HTML5 canvas element. For each of these canvas elements, you can add an event to listen for "click" events or such. That way, you can detect clicks on each individual PDF page and do something with it.

In your case, you might want to listen for the "mousedown" event to get the starting position of the click and then for the "mouseup" event to get the end position. With these two positions, you can draw a rect.

Best,

Julian

PS: Please don't use flash!


On Monday, July 9, 2012 6:15:12 PM UTC+2, Brendan Dahl wrote:

Viren

unread,
Jul 11, 2012, 4:24:37 AM7/11/12
to mozilla.d...@googlegroups.com, mozilla-d...@lists.mozilla.org, dev-p...@lists.mozilla.org, vire...@idyllic-software.com
On Tuesday, July 10, 2012 1:14:59 AM UTC+5:30, Julian Viereck wrote:
> Hi Viren,
>
> > example If the User click a area of say created at date the boundary of the selected area should be sent to the server
> >
> > Now I googling around I found that Pdf.js can handle the rendering of pdf in browser but can there be by any chance can I associate the event with the PDF pages as I mention below or should I look for some other solution like flash
> >
> > I hoping will get and answer for this is pdf.js group
>
> The PDF's pages are rendered each onto one HTML5 canvas element. For each of these canvas elements, you can add an event to listen for "click" events or such. That way, you can detect clicks on each individual PDF page and do something with it.
>
> In your case, you might want to listen for the "mousedown" event to get the starting position of the click and then for the "mouseup" event to get the end position. With these two positions, you can draw a rect.
>
> Best,
>
> Julian
>
> PS: Please don't use flash!
>
>
> On Monday, July 9, 2012 6:15:12 PM UTC+2, Brendan Dahl wrote:
> > Resending this message as it was accidentally discarded:
> >
> > Hello Everyone,
> > I have a scenario where I been asked to make online PDF viewer and on viewing mode the user would select certain area of the PDF and upon selection the marked area boundary w.r.s.t pdf should sent to the server.
> >
> > example If the User click a area of say created at date the boundary of the selected area should be sent to the server
> >
> > Now I googling around I found that Pdf.js can handle the rendering of pdf in browser but can there be by any chance can I associate the event with the PDF pages as I mention below or should I look for some other solution like flash
> >
> > I hoping will get and answer for this is pdf.js group
> >
> > Regards
> > Viren

Hi Julian Viereck,
Thanks a ton for the answer but is there any sample code that describe how to apply event to the pdf page that will definitely help

Regards
Viren Negi
0 new messages