PDFTron PDF Annotations - Video & Audio Streaming

700 views
Skip to first unread message

Tino

unread,
Mar 30, 2012, 12:53:48 PM3/30/12
to PDFTron PDFNet SDK, jmil...@realmdigital.co.za
Good day,

I am currently trialing out the PDFTron library for Android, with a
view to purchasing the licence once it meets our organisation's needs.

I am trying to stream Youtube videos as well as other externally-
hosted video and audio clips. I have created PDFs with all these
annotations of type 'e_Link' and actions of Type 'e_URI'. My question
is, is it possible to embed a video/audio clip that is not on the
device using the URL? If so, can you please point me to the right
direction. I also need to know if it is possible to add click handlers
to annotations so that if I click on an annotation, I can trigger a
new Activity or View.

I have tried an example that I saw on the internet about embedding
flash videos (http://groups.google.com/group/pdfnet-sdk/msg/
be4edb9ca95ccf99), but I am getting a RuntimeException which I cannot
understand. I am getting this exception message: 're-throw on
exception class missing constructor'. It doesn't say much about the
root of the error and there is no stack trace. The error is thrown
once my code hits the 'FileSpec fs = FileSpec.create(doc, mediaFile,
true);' line.

Your help is greatly appreciated.

Regards,
Tinotenda Mundangepfupfu

Support

unread,
Mar 30, 2012, 4:41:51 PM3/30/12
to pdfne...@googlegroups.com, jmil...@realmdigital.co.za
 

Based on your description it seems that you want to support streaming external content which is different from embedded multimedia annotations (which is covered in the given article).

 

This is not supported by PDF spec, however nothing prevents you from customizing link annotation and extending your app to support this use case scenario.

 

Since you created annotation of type 'e_Link' and actions of Type 'e_URI' you could also add some custom entries in the annotation or action dictionary...  For example:

 

pdftron.PDF.Action act = pdftron.PDF.Action.CreateURI(doc.GetSDFDoc());

pdftron.PDF.Annots.Link link = pdftron.PDF.Annots.Link.Create(doc.GetSDFDoc(), new Rect(85, 458, 503, 502), act);

 

pdftron.SDF.Obj dict = link.GetSDFObj();

dict.PutBool("My multimedia annot", true);

dict.PutName("MyString", "foo:bar, some parameter for streaming... if required etc");

...

 

-------

 

When a user taps on a link annotation you can identify the annotation that is clicked (tapped) on. This is done in the tools library which is provided in the source code form with a license purchase or using pdfview.GetAnnotaAt(x,y). You can identify your multimedia annotation by querying for the custom tag:

 

Annot a = ...

pdftron.SDF.Obj my_tag = a.GetSDFObj().FindObj("My multimedia annot ");

if (my_tag != null && my_tag.GetBool())  {

     string my_params = a.GetSDFObj().FindObj("MyString").GetName();

      ... use custom parameters and URL from associated action to stream remote data.

}

 

For streaming & playing remote multimedia you would use platform APIs which are available on both Android and iOS.

Tino

unread,
Mar 30, 2012, 6:18:29 PM3/30/12
to PDFTron PDFNet SDK, Tino Mundangepfupfu
Hi,

Thanks for the response and the pointers.

However, I do not quite understand how to identify the custom
annotation on a click event. I would like to know how and where I
listen for the click events on the custom annotations so that I can
call the native android activity that streams the video/audio.

Regards,
Tino
> > be4edb9ca95ccf99<http://groups.google.com/group/pdfnet-sdk/msg/be4edb9ca95ccf99>),

Tino

unread,
Mar 30, 2012, 5:55:05 PM3/30/12
to PDFTron PDFNet SDK
Hi,

Thanks for the information.

I have understood your pointers, however, I still don't quite
understand where I query for the custom tag. How and where do I
trigger a query on an annotation click event?

Regards,
Tino

On Mar 30, 10:41 pm, Support <inin...@pdftron.com> wrote:
> > be4edb9ca95ccf99<http://groups.google.com/group/pdfnet-sdk/msg/be4edb9ca95ccf99>),

Frank Liu

unread,
Mar 30, 2012, 7:58:26 PM3/30/12
to pdfne...@googlegroups.com
The best way to listen to the events from PDFViewCtrl is through the
PDFViewCtrl.Tool and PDFViewCtrl.ToolManager interfaces. The details can be
found from http://www.pdftron.com/pdfnet/mobile/Javadoc/index.html or the
documentation from the SDK package.

Roughly speaking, you implement your ToolManager and Tool and call
PDFViewCtrl.setToolManager() when PDFViewCtrl is set up. This way,
PDFViewCtrl will send various events to your Tool. For your purpose, you
might want to use Tool.onSingleTapConfirmed() interface, in which you call
PDFViewCtrl.getAnnotationAt() to find the annotation where it is clicked. If
a custom annotation is clicked, you can start streaming the content. Note
that PDFViewCtrl is derived from android.view.ViewGroup, therefore you can
call PDFViewCtrl.addView() to add a widget for displaying a video.

It is worth mentioning that the SDK contains a library tools.jar, which is
an add-on of the bare bone PDFViewCtrl. It is based on the two interfaces
mentioned above and implements various GUI features such as text search,
text selection, annotation handling, form filing, etc. It is used by the
PDFViewCtrlDemo with the following two lines

pdftron.PDF.Tools.ToolManager tm = new
pdftron.PDF.Tools.ToolManager();
mPDFView.setToolManager(tm);

in PDFViewCtrlDemo.java. The source code of tools.jar is available to
licensed customers for full customization, but you are free to implement
your own.

Hi,

Regards,
Tino

--
You received this message because you are subscribed to the "PDFTron PDFNet
SDK" group. To post to this group, send email to sup...@pdftron.com
To unsubscribe from this group, send email to
pdfnet-sdk-...@googlegroups.com. For more information, please visit
us at http://www.pdftron.com

Anderson Konzen

unread,
Apr 22, 2014, 3:35:06 PM4/22/14
to pdfne...@googlegroups.com
Update: Starting with version 6.1.0 of the Android PDFNet SDK, the Tools library is now shipped as an Android Library, and its source code can be found in the samples folder. The package does not include the Tools.jar anymore, and you now have the flexibility to include the source directly into your project or create a separate library for your projects.

pdfnet-sdk-unsubscribe@googlegroups.com. For more information, please visit
us at http://www.pdftron.com

Reply all
Reply to author
Forward
0 new messages