'
'NOTA:
' Definir en Starter
'Dim PdfActualPage As Int = 0
'
#Region Project Attributes
#ApplicationLabel: PDF Viewer
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#BridgeLogger: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#AdditionalJar: android-pdf-viewer.aar
#AdditionalJar: com.android.support:support-v4
#AdditionalJar: Pdfium.aar
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pdf As PdfiumCore
Private PDFView1 As PDFView
Private btnFirst As Button
Private btnPrev As Button
Private lblPages As Label
Private btnNext As Button
Private btnLast As Button
Private glPages As Int
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")
'
pdf.Initialize("PDFium")
File.Copy(File.DirAssets,"sample.pdf",File.DirInternal,"sample.pdf")
Dim cfg As Configurator = PDFView1.fromUri(File.DirInternal,"sample.pdf")
cfg.SetEventname("PDFium")
cfg.autoSpacing(True).enableSwipe(True).pageSnap(True).swipeHorizontal(False).addOnErrorListener.addOnLoadCompleteListener.addOnPageChangeListener.addOnPageErrorListener.addOnTapListener.load
End Sub
Sub PDFium_loadComplete(pages As Int)
Log($"PDFium_loadComplete(${pages})"$)
glPages = pages
lblPages.Text = $"${glPages}"$
'
Log(Starter.PdfActualPage)
If Starter.PdfActualPage > 0 Then
PDFView1.jumpTo(Starter.PdfActualPage)
'PDFView1.jumpTo2(Starter.PdfActualPage, False)
End If
End Sub
Sub PDFium_onInitiallyRendered(page As Int)
Log($"PDFium_onInitiallyRendered(${page})"$)
End Sub
Sub Pdfium_onTap(event As Object)
Log($"Pdfium_onTap(${event})"$)
End Sub
Sub PDFium_onPageChanged(page As Int, TotalPages As Int)
Log($"PDFium_onPageChanged(${page},${TotalPages})"$)
lblPages.Text = $"${page+1}/${glPages}"$
Starter.PdfActualPage = page
Log("Actual Page:")
Log(Starter.PdfActualPage)
End Sub
Sub PDFium_PageNum(page As Int)
Log($"PDFium_PageNum(${page})"$)
End Sub
Sub PDFium_Show()
Log($"PDFium_Show()"$)
End Sub
Sub Pdfium_onLayerDrawn(cnvs As Object, arg1 As Float, arg2 As Float, arg3 As Int)
Dim jocnvs As JavaObject = cnvs ' Honestly i don´t know what we can do with it :D
' The Canvas is a android.view.DisplayListCanvas
Log($"Pdfium_onLayerDrawn(${arg1},${arg2},${arg3} (Zoom = ${PDFView1.Zoom}))"$)
End Sub
Sub Activity_Resume
Log("Activity_Resume")
Log(Starter.PdfActualPage)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnFirst_Click
PDFView1.jumpTo2(0,False)
End Sub
Sub btnPrev_Click
PDFView1.jumpTo2(PDFView1.CurrentPage-1,False)
End Sub
Sub lblPages_Click
End Sub
Sub btnNext_Click
PDFView1.jumpTo2(PDFView1.CurrentPage+1,False)
End Sub
Sub btnLast_Click
PDFView1.jumpTo2(glPages-1,False)
End Sub