Introduction
PrimePDFViewer is an App Inventor extension developed by Akshat Developer that allows you to seamlessly integrate PDF viewing functionality into your app. With a wide range of customizable options, this extension enables you to view PDF files offline without the need for a web viewer. The extension provides various methods and properties to enhance the user experience of viewing PDFs within your app.
Contact Information
- Developer: Akshat Developer
- Contact Author: Telegram
Blocks
Methods
1. LoadLibraries
- Description: Loads the native libraries required by the extension.
- Parameters:
libs
(type: text) - A string containing the names of the native libraries.
2. LoadFromAssets
- Description: Loads a PDF file from assets.
- Parameters:
assetName
(type: text) - The name of the asset containing the PDF file.password
(type: text) - Password for the PDF file (leave blank if not applicable).
3. LoadFromFilePath
- Description: Loads a PDF file from the file path.
- Parameters:
filePath
(type: text) - The file path of the PDF file.password
(type: text) - Password for the PDF file (leave blank if not applicable).
4. LoadFromUri
- Description: Loads a PDF file from the provided URI.
- Parameters:
fileUri
(type: text) - The URI of the PDF file.password
(type: text) - Password for the PDF file (leave blank if not applicable).
5. LoadFromUrl
- Description: Loads a PDF file from an online URL.
- Parameters:
url
(type: text) - The URL of the PDF file.useCache
(type: boolean) - Indicates whether to use cached files.password
(type: text) - Password for the PDF file (leave blank if not applicable).
6. SetScrollBarCorners
- Description: Sets the corner radius for the scrollbar used in the PDFView.
- Parameters:
topLeft
(type: number) - Top-left corner radius.bottomLeft
(type: number) - Bottom-left corner radius.topRight
(type: number) - Top-right corner radius.bottomRight
(type: number) - Bottom-right corner radius.
7. SetPositionOffset
- Description: Sets the position offset of the PDFView with an option to move the handle.
- Parameters:
offset
(type: number) - The offset value.moveHandle
(type: boolean) - Indicates whether to move the handle.
8. StopFling
- Description: Stops fling animation in the PDFView.
- Parameters: None
9. JumpTo
- Description: Jumps to the provided page, with an option for animated transition.
- Parameters:
page
(type: number) - The page number.animate
(type: boolean) - Indicates whether to perform the action in an animated way.
10. Recycle
- Description: Resets the PDF View, removing the currently loaded PDF.
- Parameters: None
11. LoadPages
- Description: Reloads the pages of the PDF.
- Parameters: None
12. MoveTo
- Description: Moves to the provided x and y offset, with an option to move the handle.
- Parameters:
x
(type: number) - The x offset.y
(type: number) - The y offset.moveHandle
(type: boolean) - Indicates whether to move the handle.
13. PerformPageSnap
- Description: Performs snap for pages of the loaded PDF.
- Parameters: None
14. MoveRelativeTo
- Description: Moves with the provided values with the current offset.
- Parameters:
x
(type: number) - The x value.y
(type: number) - The y value.
15. Zoom
- Description: Zooms to the current PDF Page with the specified amount.
- Parameters:
zoom
(type: number) - The zoom amount.
16. FitToWidth
- Description: Fits the page to full width.
- Parameters:
page
(type: number) - The page number.
17. GetPageHeight
- Description: Returns the height of the page at the provided number.
- Parameters:
page
(type: number) - The page number.
- Return Type: number
18. GetPageWidth
- Description: Returns the width of the page at the provided number.
- Parameters:
page
(type: number) - The page number.
- Return Type: number
19. ToRealScale
- Description: Converts the provided size to real scale.
- Parameters:
size
(type: number) - The size value.
- Return Type: number
20. ToCurrentScale
- Description: Converts the provided size to the current scale.
- Parameters:
size
(type: number) - The size value.
- Return Type: number
21. ResetZoom
- Description: Resets the zoom. The action is performed in an animated way if true is provided for the parameter named 'animate'.
- Parameters:
animate
(type: boolean) - Indicates whether to perform the action in an animated way.
22. ZoomWithAnimation
- Description: Zooms in with the provided scale.
- Parameters:
scale
(type: number) - The scale value.
23. ZoomWithAnimationTo
- Description: Zooms to the provided x and y points.
- Parameters:
x
(type: number) - The x point.y
(type: number) - The y point.scale
(type: number) - The scale value.
24. GetPageAtPositionOffset
- Description: Gets the page present at the provided position offset.
- Parameters:
offset
(type: number) - The position offset.
- Return Type: number
25. GetPdfMetadata
- Description: Gets the metadata from the provided PDF file.
- Parameters: None
26. GetLinksAt
- Description: Gets a list of links present in the provided PDF page.
- Parameters:
page
(type: number) - The page number.
- Return Type: list
27. GetSelection
- Description: Returns the current selected text in the PDFView.
- Parameters: None
- Return Type: text
28. HasSelection
- Description: Returns if the PDFView has text selected.
- Parameters: None
- Return Type: boolean
29. SelectText
- Description: Selects the text on the provided page from the provided start and end index.
- Parameters:
page
(type: number) - The page number.start
(type: number) - The start index.end
(type: number) - The end index.
30. IsCachedLocally
- Description: Returns if the cached PDF file for the provided URL is available.
- Parameters:
url
(type: text) - The URL of the PDF file.
- Return Type: boolean
31. GetFilePathForCache
- Description: Returns the path for the cached PDF file of the provided URL. Returns empty text if no cache is available.
- Parameters:
url
(type: text) - The URL of the PDF file.
- Return Type: text
32. ClearCacheForUrl
- Description: Deletes the cache for the provided URL if available.
- Parameters:
url
(type: text) - The URL of the PDF file.
33. ClearSelection
- Description: Clears the currently selected text on the PDF page.
- Parameters: None
34. StopSearch
- Description: Stops the search in the PDFView.
- Parameters: None
35. GoToPrevious
- Description: Move to the previous result of the search.
- Parameters: None
36. GoToNext
- Description: Move to the next result of the search.
- Parameters: None
37. Search
- Description: Search for the provided text in the PDFView.
- Parameters:
text
(type: text) - The text to search for.
38. RedrawSearch
- Description: Redraws the selection and search layout.
- Parameters: None
Block Properties
1. Layout
- Description: Sets the layout for showing the PDFView.
- Type: component
- ReadWrite: write-only
2. BackgroundColor
- Description: Returns the background color for the PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFF888888
3. SelectionColor
- Description: Returns the color used for selection of text in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFF00FFFF
4. SelectionHandleColor
- Description: Returns the color used for the selection handle of text in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFF00FFFF
5. SearchResultHighlightColor
- Description: Returns the color used for the highlighting of search results in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFFFFFF00
6. ScrollBarColor
- Description: Returns the color of the scrollbar shown in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFFCCCCCC
7. ScrollBarStrokeColor
- Description: Returns the color of the stroke of the scrollbar shown in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFF000000
8. ScrollBarTextColor
- Description: Returns the color of the text of the scrollbar shown in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: &HFF000000
9. ScrollBarStrokeWidth
- Description: Returns the width for the stroke of the scrollbar shown in PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: 1
10. PositionOffset
- Description: Returns the current position offset of the PDFView.
- Type: number
- ReadWrite: read-write
11. PageCount
- Description: Returns the page count of the currently loaded file in the PDFView.
- Type: number
- ReadWrite: read-only
12. SwipeEnabled
- Description: Returns if swipe is enabled in the PDFView.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
13. NightMode
- Description: Returns if night mode is enabled in the PDFView.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
14. DoubleTapEnabled
- Description: Returns if double tap to zoom is enabled.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
15. Recycled
- Description: Returns if the PDF View is recycled.
- Type: boolean
- ReadWrite: read-only
16. PageFillsScreen
- Description: Returns if the currently loaded page fills the screen.
- Type: boolean
- ReadWrite: read-only
17. DocumentFillsView
- Description: Returns if the currently loaded PDF fills the layout.
- Type: boolean
- ReadWrite: read-only
18. CurrentPage
- Description: Returns the page being currently shown in the PDFView.
- Type: number
- ReadWrite: read-only
19. CurrentXOffset
- Description: Returns the current x offset of PDF View.
- Type: number
- ReadWrite: read-only
20. CurrentYOffset
- Description: Returns the current y offset of PDF View.
- Type: number
- ReadWrite: read-only
21. Zoom
- Description: Returns the zoom amount of the PDF View.
- Type: number
- ReadWrite: read-only
22. Zooming
- Description: Returns if the user is currently zooming in the PDF View.
- Type: boolean
- ReadWrite: read-only
23. DefaultPage
- Description: Sets the default page for the PDFView.
- Type: number
- ReadWrite: write-only
- DefaultValue: 1
24. MinZoom
- Description: Returns the minimum zoom for PDF View.
- Type: number
- ReadWrite: read-write
- DefaultValue: 1
25. MidZoom
- Description: Returns the mid-zoom for PDF View.
- Type: number
- ReadWrite: read-write
- DefaultValue: 1.75
26. MaxZoom
- Description: Returns the maximum zoom for PDF View.
- Type: number
- ReadWrite: read-write
- DefaultValue: 3
27. UseBestQuality
- Description: Returns if the pages are being loaded in the best quality.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
28. SwipeOrientation
- Description: Returns the swipe orientation for the PDFView.
- Type: text
- ReadWrite: read-write
- DefaultValue: Vertical
29. AnnotationRenderingEnabled
- Description: Returns if the PDF View should render annotations.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
30. RenderDuringScale
- Description: Returns if PDF View will render pages even during scale.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
31. AntiAliasing
- Description: Returns if anti-aliasing is enabled for the PDF View.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
32. AutoSpacing
- Description: Returns if auto-spacing for PDF pages should be enabled.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
33. Spacing
- Description: Returns the amount of spacing between PDF Pages.
- Type: number
- ReadWrite: read-write
- DefaultValue: 0
34. PageFling
- Description: Returns if fling is enabled for PDF Pages.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
35. FitPolicy
- Description: Returns the policy used for fitting the PDF pages.
- Type: text
- ReadWrite: read-write
- DefaultValue: Both
36. FitEachPage
- Description: Returns if PDF View is fitting each page.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
37. PageSnap
- Description: Returns if snapping is enabled for PDF Pages.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: False
38. LongPressEnabled
- Description: Returns if long press is enabled for the PDFView.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
39. TextSelectable
- Description: Returns if the text of the page is selectable.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
40. PaddingTop
- Description: Returns the top padding for the PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: 20
41. PaddingBottom
- Description: Returns the bottom padding for the PDFView.
- Type: number
- ReadWrite: read-write
- DefaultValue: 20
42. ScrollBarEnabled
- Description: Returns if the scrollbar for the PDFView should be enabled.
- Type: boolean
- ReadWrite: read-write
- DefaultValue: True
Events
1. LibrariesLoaded
- Description: Event triggered when all the native libraries were loaded successfully.
- Parameters: None
2. ErrorLoadingLibraries
- Description: Event triggered when an error was encountered while loading the native libraries.
- Parameters:
error
(type: text) - The error message.
3. FileLoaded
- Description: Event triggered when the PDF file is loaded.
- Parameters:
totalPages
(type: number) - The total number of pages in the loaded PDF file.
4. ErrorOccurred
- Description: Event triggered when an error occurred while loading PDF files.
- Parameters:
error
(type: text) - The error message.
5. PageDrawn
- Description: Event triggered when a page is rendered.
- Parameters:
page
(type: number) - The page number.height
(type: number) - The height of the rendered page.width
(type: number) - The width of the rendered page.
6. AllPagesDrawn
- Description: Event triggered when all pages are drawn.
- Parameters: None
7. PageChanged
- Description: Event triggered when the current page has changed.
- Parameters:
page
(type: number) - The new current page number.totalCount
(type: number) - The total number of pages.
8. PageScrolled
- Description: Event triggered when the PDF view was scrolled.
- Parameters:
page
(type: number) - The current page number.positionOffset
(type: number) - The position offset.
9. DocumentRendered
- Description: Event triggered when the whole document is successfully rendered.
- Parameters:
totalPages
(type: number) - The total number of pages in the rendered document.
10. Tap
- Description: Event triggered when the user tapped on a point in the PDF view.
- Parameters:
x
(type: number) - The x-coordinate of the tapped point.y
(type: number) - The y-coordinate of the tapped point.
11. LongPress
- Description: Event triggered when the user long clicked at a point in the PDF view.
- Parameters:
x
(type: number) - The x-coordinate of the long-pressed point.y
(type: number) - The y-coordinate of the long-pressed point.
12. PageError
- Description: Event triggered when an error was encountered while loading a page.
- Parameters:
page
(type: number) - The page number where the error occurred.error
(type: text) - The error message.
13. LinkClicked
- Description: Event triggered when the user clicked on a link present in the PDF.
- Parameters:
link
(type: text) - The URL of the clicked link.
14. SelectionChanged
- Description: Event triggered when the selection for PDFView's page has changed.
- Parameters:
hasSelection
(type: boolean) - Indicates if there is currently a text selection.
15. GotMetadata
- Description: Event triggered when the metadata from the current PDF file is retrieved.
- Parameters:
-
title
(type: text) - The title of the PDF. -
author
(type: text) - The author of the PDF. -
subject
(type: text) - The subject of the PDF. -
keywords
(type: text) - The keywords associated with the PDF.
-
16. Searching
- Description: Event triggered when the PDFView is searching for text.
- Parameters:
query
(type: text) - The text being searched.
17. SearchCompleted
- Description: Event triggered when the search in the PDFView is completed.
- Parameters:
query
(type: text) - The text for which the search is completed.resultsCount
(type: number) - The number of search results.
18. SearchResultClicked
- Description: Event triggered when the user clicks on a search result.
- Parameters:
pageIndex
(type: number) - The page index of the clicked search result.x
(type: number) - The x-coordinate of the clicked point.y
(type: number) - The y-coordinate of the clicked point.
Example Usage
Here is an example of how you can use the PrimePDFViewer extension in your App Inventor project:
-
Load Libraries:
- Use the
LoadLibraries
method to load the required native libraries.
PrimePDFViewer.LoadLibraries("libname.zip")
- Use the
-
Load PDF from Assets:
- Use the
LoadFromAssets
method to load a PDF file from the assets.
PrimePDFViewer.LoadFromAssets("example.pdf")
- Use the
-
Set Layout:
- Set the layout for showing the PDFView using the
Layout
property.
PrimePDFViewer.Layout(ComponentName)
- Set the layout for showing the PDFView using the
-
Customize Appearance:
- Customize the appearance using the various properties provided by the extension, such as
BackgroundColor
,SelectionColor
,ScrollBarColor
, etc.
PrimePDFViewer.BackgroundColor(&HFFEEEEEE) PrimePDFViewer.SelectionColor(&HFFFF0000) PrimePDFViewer.ScrollBarColor(&HFF333333)
- Customize the appearance using the various properties provided by the extension, such as
-
Handle Events:
- Handle events such as
FileLoaded
,PageChanged
,LinkClicked
, etc.
when PrimePDFViewer.FileLoaded do // Do something when the PDF file is loaded when PrimePDFViewer.PageChanged(page, totalCount) do // Do something when the page is changed when PrimePDFViewer.LinkClicked(link) do // Do something when a link is clicked
- Handle events such as
-
Implement PDF Searching:
- Implement PDF text searching using the
Search
method and handle events such asSearching
,SearchCompleted
,SearchResultClicked
.
PrimePDFViewer.Search("example text")
when PrimePDFViewer.Searching do // Do something when the search is in progress when PrimePDFViewer.SearchCompleted(query, resultsCount) do // Do something when the search is completed when PrimePDFViewer.SearchResultClicked(pageIndex, x, y) do // Do something when a search result is clicked
- Implement PDF text searching using the
-
Clear Selection:
- Clear the currently selected text using the
ClearSelection
method.
PrimePDFViewer.ClearSelection()
- Clear the currently selected text using the
-
Clear Cache:
- Clear the cache for a specific URL using the
ClearCacheForUrl
method.
PrimePDFViewer.ClearCacheForUrl("https://example.com/example.pdf")
- Clear the cache for a specific URL using the
-
Implement Zoom Controls:
- Implement zoom controls using methods such as
Zoom
,ResetZoom
,ZoomWithAnimation
, etc.
PrimePDFViewer.Zoom(1.5)
PrimePDFViewer.ResetZoom(true)
PrimePDFViewer.ZoomWithAnimation(2.0)
- Implement zoom controls using methods such as
-
Select Text:
- Select text on a specific page using the
SelectText
method.
PrimePDFViewer.SelectText(1, 10, 20)
- Select text on a specific page using the
-
Get PDF Metadata:
- Retrieve metadata from the loaded PDF using the
GetPdfMetadata
method.
PrimePDFViewer.GetPdfMetadata()
when PrimePDFViewer.GotMetadata(title, author, subject, keywords) do // Do something with the retrieved metadata
- Retrieve metadata from the loaded PDF using the
-
Customize Scrollbar Corners:
- Customize the corners of the scrollbar using the
SetScrollBarCorners
method.
PrimePDFViewer.SetScrollBarCorners(10, 0, 0, 10)
- Customize the corners of the scrollbar using the
-
Set Default Page:
- Set the default page for the PDFView using the
DefaultPage
property.
PrimePDFViewer.DefaultPage(3)
- Set the default page for the PDFView using the
-
Customize Padding:
- Customize the top and bottom padding using the
PaddingTop
andPaddingBottom
properties.
PrimePDFViewer.PaddingTop(30) PrimePDFViewer.PaddingBottom(30)
- Customize the top and bottom padding using the
-
Customize Swipe Orientation:
- Customize the swipe orientation using the
SwipeOrientation
property.
PrimePDFViewer.SwipeOrientation("Horizontal")
- Customize the swipe orientation using the
-
Get Page Dimensions:
- Get the dimensions of a specific page using the
GetPageHeight
andGetPageWidth
methods.
height := PrimePDFViewer.GetPageHeight(1) width := PrimePDFViewer.GetPageWidth(1)
- Get the dimensions of a specific page using the
-
Implement Long Press Event:
- Implement the long-press event using the
LongPress
event.
when PrimePDFViewer.LongPress(x, y) do // Do something when a long-press occurs
- Implement the long-press event using the
Important Notes
- Ensure that the PDF file is accessible and readable by the app.
- It is recommended to handle errors using the
ErrorOccurred
andErrorLoadingLibraries
events for better user experience.
Version History
- Version 1.0 (26 January 2024):
- Initial release of the PrimePDFViewer extension.
- Version 2.0 (31 January 2024):
- Major updates with many customization and new features.
Terms of Use
By using the PrimePDFViewer extension, you agree to the following terms:
- The extension is provided "as is," without warranty of any kind, express or implied.
- The developer (Akshat Developer) holds no responsibility for any damage or loss caused by the use of this extension.
- You are responsible for complying with the licensing terms of the native libraries used by the extension.
- The extension may be subject to future updates or modifications.
- Unauthorized distribution or sale of the extension is strictly prohibited.
Support
For support and inquiries, please contact the developer (Akshat Developer) through Telegram or in the community itself.
Pricing
Before considering to buy this extension make sure that you have read and agreed to Extension Buying Policy. If not, please refrain to buy this extension
PrimePDFViewer is priced at 499 Indian Rupees (UPI) or 7.99 US Dollars (PayPal). Additional features such as search text and selectable text options can be unlocked for an extra cost of 1.5 US Dollars or 100 Indian Rupees
Contact me here in the community or in Telegram for other payment methods.
Liked My Work?
Support me on: