How do I access a single page PDF view in iOS mobile SDK?

52 views
Skip to first unread message

Support

unread,
Feb 8, 2013, 2:02:30 PM2/8/13
to pdfne...@googlegroups.com
Q:
I am developing a PDF iOS app based on PDFTron SDK.

I'd like to be able to access the view of the single PDF page as I need to place widgets relative to the page and not to the controller that contains all of them.  Is there any way to achieve that?

-------
A:

There is actually not a view for a single PDF page. For rendering efficiency, the entire PDF layout is rendered as a series of tiles (like Google Maps), where one tile could overlap multiple pages. If you want to place widgets on a page, you will need to add them to the ContainerView (as shown in the forum example sent by Tomas), which is the view that is scrolled around by a scroll viewer. To know where on the container view to add the widgets, you will need to translate between "Screen" coordinates (the area currently visible in the PDFViewCtrl) and "Page" coordinates. There are a number of PDViewCtrl methods to help with coordinate conversion, notably ConvScreenPtToPagePt and ConvPagePtToScreenPt. Adding the scroll position of PDFViewCtrl (using GetHScrollPos and GetVScrollPos) to the screen coordinates will give the location on which to add widgets to the ContainerView. One last thing to note is that PDF defines the lower left corner of the page as the origin of the page. 

Licensed users are provided with the source code to libTools.a (where text selection, annotation creation, editing, etc. is implemented), which can act as a good set of sample code for making these sorts of customizations to PDFViewCtrl.
 
In case you really need to access individual page Bitmaps (e.g. for thumbanils) or to build your own control from scratch you can use 'pdftron.PDF.PDFDraw' as shown in PDFDraw sample (http://www.pdftron.com/pdfnet/samplecode/PDFDrawTest.m) - which is also included as part of all mobiles SDKs. Please note that this is relatively low-level rasterizer stuff and requirements can be implemented by simply configuring PDFViewCtrl and tweaking the tools source code.
 
 
 
 
 
 
Reply all
Reply to author
Forward
0 new messages