[Free] PDF Viewer Extension - An In App PDF Renderer and Viewer

PDF Viewer

An extension for MIT App Inventor 2.
Developed by The K Studio.

:page_facing_up: PDF Viewer Extension for AI2 – Load, View & Navigate PDFs Seamlessly! :rocket:

Bring professional PDF viewing to your AI2 apps with the PDF Viewer Extension! Whether you're displaying ebooks, invoices, reports, study materials, or user manuals, this extension ensures smooth, efficient, and customizable PDF rendering.

:fire: Key Features:

  • :white_check_mark: Load PDFs from Multiple Sources – Assets, Storage, URLs, and Content URIs
  • :white_check_mark: Single-Page & Continuous Scroll Modes – Perfect for reading long documents :scroll:
  • :white_check_mark: Adjustable Render Quality – Balance between speed & clarity :zap::framed_picture:
  • :white_check_mark: Save PDF Pages as Images – Export selected pages or save all in one click! :camera_flash:
  • :white_check_mark: Zoom & Pan Support – Easily zoom into details :mag:
  • :white_check_mark: Customizable Background Color – Adjust for dark mode or aesthetic needs :art:
  • :white_check_mark: Page Navigation – Jump to specific pages instantly :fast_forward:
  • :white_check_mark: Page Snap Feature – Enable or disable smooth swiping between pages :raised_hand_with_fingers_splayed:
  • :white_check_mark: Total Page Count Retrieval – Get the number of pages dynamically :bookmark_tabs:
  • :white_check_mark: Optimized for Performance – Loads PDFs efficiently without lag :zap:
  • :white_check_mark: Works in Both Portrait & Landscape :arrows_counterclockwise:
  • :white_check_mark: Light Weight Extension – Since this does not uses any PDF Viewer library!

:memo: Specifications


:package: Package: com.thekstudio.pdfviewer
:floppy_disk: Size: 64.00 KB
:gear: Version: 1.0
:iphone: Minimum API Level: 7
:date: Updated On: 2025-02-28T18:30:00Z
:computer: Built & documented using: FAST-CLI v2.4.2

Events:

PDFViewer has total 7 events.

DownloadProgress

DownloadProgressBlock

Triggered when download progress updates.

Parameter Type
progress number

RenderProgress

RenderProgressBlock

Triggered to indicate rendering progress.

Parameter Type
progress number

PDFLoaded

PDFLoadedBlock

Triggered when a PDF is successfully loaded with the total number of pages.

Parameter Type
totalPages number
pdfFileName text

PageChanged

PageChangedBlock

Triggered when the page changes.

Parameter Type
currentPage number

OnError

OnErrorBlock

Triggered when an error occurs.

Parameter Type
errorMessage text

PageSaved

PageSavedBlock

Triggered when a page is successfully saved. Return saved page file path.

Parameter Type
pageIndex number
filePath text

AllPagesSaved

AllPagesSavedBlock

Triggered when all pages are successfully saved. Returns the saved pages directory path.

Parameter Type
outputDir text

Methods:

PDFViewer has total 10 methods.

LoadPDF

Loads a PDF from the given file path and loads PDF View in the given component layout. Supports loading from assets, storage, URL, or content URIs. Specify 'test.pdf' for assets, '/storage/emulated/0/test.pdf' for storage, 'http://example.com/test.pdf' for URL, and 'content://...' for content URIs.

Parameter Type
filePath text
component component
orientation Orientation (helper blocks)
enableSnap boolean

ClosePDF

ClosePDFBlock

Closes the currently opened PDF.

GetTotalPages

GetTotalPagesBlock

Returns the total number of pages in the PDF.

GetCurrentPage

GetCurrentPageBlock

Returns the currently visible page index.

GoToPage

GoToPageBlock

Jumps to a specific page in the PDF.

Parameter Type
pageIndex number

GetASD

GetASDBlock

Returns the app's specific directory (ASD).

GetPDFFileName

GetPDFFileNameBlock

Returns the file name of the currently opened PDF.

SavePage

SavePageBlock

Saves the PDF page to the given file path as an image.

Parameter Type
pageIndex number
outputPath text

SaveAllPages

SaveAllPagesBlock

Saves all rendered PDF pages to the given directory.

Parameter Type
outputDir text

GetRenderedPageCount

GetRenderedPageCountBlock

Returns the total number of pages rendered.

Setters:

PDFViewer has total 2 setter properties.

BackgroundColor

BackgroundColorBlock

Specifies the background color of the PDF Viewer.

  • Input type: color
  • Default value: WHITE (&HFFFFFFFF)

RenderQuality

RenderQualityBlock

Sets the rendering quality between 30 to 500. Default is 100. Set lower quality for better performance.

  • Input type: integer
  • Default value: 100

USAGE:

Test APK:

Test.apk - Google Drive

Video:

DOWNLOAD:

v1.0 com.thekstudio.pdfviewer.aix (64.0 KB)

Test.aia (1.0 MB)

Note: Drag ListView AI2 component to the Screen1 to add RecyclerView library to the project which is required for the extension to work.

I'm looking for sponsors to support the release of this extension with a total contribution of $25.

Leave a like if found useful :heart:

11 Likes

Extension is free now!

3 Likes

Thank you so much.:heart_eyes::saluting_face::rocket:

can you add this things, which also work like drive pdf viewer? when click and slide then also pdf page slide up & down.

image

or,

image

1 Like

I will try if this can be done in next update.

1 Like

For me, on testing your example aia, would not load the asset pdf. Had to do this, using the File component (in companion app):

pdf from file and url works OK.

1 Like

Yes, this is expected behavior as assets are not accessible from companion. But when file scope set to assets it will work as it generate a full path from companion assets.

If you built the APK then this will work from assets as well without full path.

This limitation is only for file from assets in companion.

2 Likes

Good job :clap:t2:

1 Like

one more things, pdf use caches to load or where it load in storage?
if anyone wants to download it take again data?

For rendering PDF pages it uses cache memory only for the current PDF instance, so when rendering another PDF old cache will be cleared so that next PDF will be freshly loaded.

Yes, intentionally I am not using cache for downloaded file as it may corrupt in case of network fail and PDF may not loaded, so when loading every PDF from online source it will freshly downloaded as temporary file and then loaded.

If you want to avoid re-download then you may use your own download procedure to first download the PDF in ASD or local storage and load it.

I see the pdf library which are u using, is updated with newer version.
it may be help to add some new feature in pdf viewer extension.
could you pls check the latest library. :blush:

???

Taifun

As I mentioned earlier, it does not uses any external library. It is based PDF renderer and viewer using recycler view.

I will add additional features as I get enough time.

1 Like