Re: PDFTron Android on Fragment

442 views
Skip to first unread message

Frank Liu

unread,
Aug 9, 2012, 2:41:53 PM8/9/12
to pdfne...@googlegroups.com
Yes, you can manage/load a pdf into a fragment. Quoting Android developer website, "Fragments behave somewhat like a nested activity that can define its own layout and manage its own lifecycle."

Since fragments have their own layout, you can easily add a PDFViewCtrl to it. For example:

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
    
    <pdftron.PDF.PDFViewCtrl
      android:id="@+id/pdfviewctrl"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scrollbars = "vertical|horizontal"/>
</LinearLayout >

On your fragment's onCreate() method you can get the reference to this PDFViewCtrl and then load the document into it. Just remember that fragments have a slightly different life-cycle than activities, and depending on what you want to achieve you need to have that in mind.

You can also take a look in the mobile API for Android: http://www.pdftron.com/pdfnet/mobile/Javadoc/index.html

On Thursday, August 9, 2012 8:42:53 AM UTC-7, Giuseppe Vacatello wrote:
Hi!
Can I load a pdf into a fragment? It's the same like activity?
Thank you :)
Reply all
Reply to author
Forward
0 new messages