Hi all,
I've tried to learn the Icefairy333 's pdfviewer demo. I've error message and wonder about Addview() command. Please help me to clearly?
P.S. zip file size 3.26 MB couldn't upload
I've tried to learn the Icefairy333 's pdfviewer demo. I've error message and wonder about Addview() command. Please help me to clearly?
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pdfv As PDFViewer
'Dim i,pc As Int=0
Dim pc As Int=0
'Dim iv
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
'*****************************************************
'*DBUtils is Code Module,We cann't use it as library *
'*****************************************************
pdfv.init
Activity.AddView(pdfv,0,0,-1,-1)
'Activity.AddView(pdfv,0,0,100%x,100%y)
'pdfv.getpdf(DBUtils.CopyDBFromAssets("UsersGuide.pdf")&"/UsersGuide.pdf")
'Cut only sub module:CopyDBFromAssets
pdfv.getpdf(CopyDBFromAssets("UsersGuide.pdf")&"/UsersGuide.pdf")
If pdfv.isValid Then
'Log("pagecount:"&pdfv.PageCount)
pdfv.scrollToPage(0)
pc=pdfv.GetPageCount
pdfv.zoom(3.0)
Else
Msgbox("Error pdf file!","Error")
Activity.Finish
Return
End If
End Sub
Sub CopyDBFromAssets (FileName As String) As String
Dim TargetDir As String
If File.ExternalWritable Then TargetDir = File.DirDefaultExternal Else TargetDir = File.DirInternal
If File.Exists(TargetDir, FileName) = False Then
File.Copy(File.DirAssets, FileName, TargetDir, FileName)
End If
Return TargetDir
End Sub
Attachments
Last edited: