1. Introduction
I was doing some work with @Juan_Antonio's KIO4_PDF extension and realised that it was possible to view ANY pdf available on the device (within reason, depending on location, Android version / API). I came up with some blocks to make it possible to view an entire pdf in a webviewer. (There are already straightforward methods for viewing pdfs locally and from online resources)
In discussion with Juan, and with his help and code, I then developed this extension which would do the same thing. There is no set path to the pdf, so the developer will need to use the getAPI block and getASD block (if needed) for version testing and application. However, once compiled, you would need to copy your pdf asset across to your ASD in order to view it in Android > 9.
The extension requires a webviewer to display the pdf.
I am not sure what would happen with really large or really long pdf files... - see Post 42 for update on a second extension that handles large files
- Latest version: 2.5
- Tested: tested on App inventor 2 (n188), in companion (2.62u) and compiled modes on Android 10 and Android 12. (Also tested on Android 7 companion)
- Released: 2021-10-23T23:00:00Z
- Last updated: 2024-03-31T23:00:00Z
- Built: using the RUSH Extension Builder by @shreyash
2022-02-25T00:00:00Z
- Now added a ViewPdfAddOn which contains a single block for reading in pdf files from Assets when the app is compiled
2. Blocks (v2.4)
3. Usage v2.3
(testing in companion Android>9)
(testing in companion Android<10)
(copy file in assets to ASD, seems to work for all Android versions that have an ASD)
(view pdf from ASD)
(html colour properties)
Usage v2.4
Usage v2.5
3. Files
AIX: ViewPDF
AIX: ViewBigPDF
4. Changelog
- 2.1
- first release
- 2.2
- added background colour for html property (Use
-2
if you want awhite
background, the colour block does not work) - added text colour for page numbers property
- (for both the above set to -1 to return to default)
- changed
copyFromAssets
>>copyFromAssetsToAsd
- added routine to delete the temporary html file on exit
- added background colour for html property (Use
- 2.3
- update to provide webviewer file access on kodular
- 2.4
- added page count property
- added page clicked returns page number to webviewstring
- added scroll to page number from webviewstring
- developer must set webviewstring = 1 when first displaying pdf
- no requirement to reload pdf when changing scroll to page
- 2.5
- added quality option, 0 - 10, where 0 is the default
- pdfaddon function now included in main extension (for loading pdfs from assets when compiled)
- AfterDisplay event added, to allow for actions once pdf is rendered and displayed (useful for progress dialog when loading large pdfs - in testing, with quality setting at 10, a 100 page pdf took @ 30 seconds to render)
5. Credits
My thanks to @Juan_Antonio, whose KIO4_PDF extension work has made this all possible.
Thanks to @vknow360 for his help with the update for file access
PDFs from MIT CTCT Curriculum, Hello It's Me, Karen Lang (copyright MIT 2021)
6. Video Demo
Enjoy , and all feedback and comments welcome.
Available for use in any MIT AppInventor projects or competitions
#####################################################################
This work by TIMAI2 is licensed under a
Creative Commons Attribution-ShareAlike 4.0 Unported License with attribution.
Please use name = TIMAI2 and link to this source page when giving credit.
#####################################################################