iOS Question PDFKit goToPage

MarcoRome

Expert
Licensed User
Longtime User
Hi All,
I found this code
written by @Semen Matusovskiy

I tried and everything works fine.
However, I would like to add the "goToPage" method to scroll the pdf to a certain page as per the documentation


I tried to add:

B4X:
Private Sub goToPage(page_go As Int)

    Dim nativeObjectMe As NativeObject
    nativeObjectMe = Me
    nativeObjectMe.RunMethod("goToPage", Array(page_go))

End Sub

But return the follow error:

Method not found: goToPage, target: <b4i_main: (null)>

it's definitely my mistake.
Having no experience with Objective-C, I wanted to know if any of you who use the same can give me a hand.
Thank you
Marco
 

Attachments

  • PDFKit_test2.zip
    509.4 KB · Views: 52

MarcoRome

Expert
Licensed User
Longtime User
I found the solution.

To go to a specific page:
B4X:
Private Sub goToPage(page_go As Int)
  nativeObjectPDFView.RunMethod("goToPage:", Array(nativeObjectPDFDocument.RunMethod("pageAtIndex:", Array(page_go))))
End Sub

To find out how many pages are in the document:
B4X:
Private Sub pagine_totale As Int
    Dim pagine_tot As Object
    pagine_tot = nativeObjectPDFDocument.GetField("pageCount")
    Return pagine_tot
End Sub
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Hi, I`m now in the journey of trying to do PDF viewing, etc. I`m completely new to the 'nativeobject' theing....
I`m trying to get current page, I see in the iOS documentation it shows "@property(nonatomic, readonly, nullable) PDFPage *currentPage;"

How do I translate that to B4i code, I`m assuming its similar to the above:
B4X:
 pagine_tot = nativeObjectPDFDocument.GetField("pageCount")

Any advise appreciated...

James
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi, I`m now in the journey of trying to do PDF viewing, etc. I`m completely new to the 'nativeobject' theing....
I`m trying to get current page, I see in the iOS documentation it shows "@property(nonatomic, readonly, nullable) PDFPage *currentPage;"

How do I translate that to B4i code, I`m assuming its similar to the above:
B4X:
 pagine_tot = nativeObjectPDFDocument.GetField("pageCount")

Any advise appreciated...

James
B4X:
    Dim current_page As Object = nativeObjectPDFDocument.RunMethod("indexForPage:",Array(nativeObjectPDFView.RunMethod("currentPage",Null)))
    Log($"Page: ${current_page}"$)
 
Upvote 0
Top