[free lib]b4aPDFViewer by Icefairy333
Now you can show pdf in B4A!
limit:support arm cpu only(because jni include)
support both English and Chinese.android2.2-android4.0(havn't test 4.1 or 4.2)
here is the example code:
b4aPdfViewer
Author: Icefairy333
Version: 1.12
download the library:
Now you can show pdf in B4A!
limit:support arm cpu only(because jni include)
support both English and Chinese.android2.2-android4.0(havn't test 4.1 or 4.2)
here is the example code:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A PdfViewer
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
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 pdfv As PDFViewer
Dim i,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")
pdfv.init
Activity.AddView(pdfv,0,0,-1,-1)
pdfv.getpdf(File.DirRootExternal&"/t.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 Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Author: Icefairy333
Version: 1.12
- PDFViewer
Methods:- BringToFront
- GetPageCount As Int
- Initialize (arg1 As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- finalize
- findOnPage (str As String, pageid As Int) As Int
- getPageBitmap (page As Int, zoom As Int, x As Int, y As Int, rotation As Int, prefXSize As Int, prefYSize As Int) As Bitmap
- getpdf (filepath As String)
you can't load pdf from assets dir - getpdf2 (filepath As String, password As String)
- init
volControl: if the vol button control pagedown or pageup - isValid As Boolean
- scrollToFindResult (n As Int)
- scrollToPage (page As Int)
- zoom (value As Float)
- Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- Tag As Object
- Top As Int
- Visible As Boolean
- Width As Int
download the library:
Attachments
Last edited by a moderator: