### Load PDF with Options Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Demonstrates loading a PDF file from various sources with a comprehensive set of configuration options. Use this to customize page rendering, swipe behavior, annotations, and more. ```java pdfView.fromUri(Uri) or pdfView.fromFile(File) or pdfView.fromBytes(byte[]) or pdfView.fromStream(InputStream) // stream is written to bytearray - native code cannot use Java Streams or pdfView.fromSource(DocumentSource) or pdfView.fromAsset(String) .pages(0, 2, 1, 3, 3, 3) // all pages are displayed by default .enableSwipe(true) // allows to block changing pages using swipe .swipeHorizontal(false) .enableDoubletap(true) .defaultPage(0) // allows to draw something on the current page, usually visible in the middle of the screen .onDraw(onDrawListener) // allows to draw something on all pages, separately for every page. Called only for visible pages .onDrawAll(onDrawListener) .onLoad(onLoadCompleteListener) // called after document is loaded and starts to be rendered .onPageChange(onPageChangeListener) .onPageScroll(onPageScrollListener) .onError(onErrorListener) .onPageError(onPageErrorListener) .onRender(onRenderListener) // called after document is rendered for the first time // called on single tap, return true if handled, false to toggle scroll handle visibility .onTap(onTapListener) .onLongPress(onLongPressListener) .enableAnnotationRendering(false) // render annotations (such as comments, colors or forms) .password(null) .scrollHandle(null) .enableAntialiasing(true) // improve rendering a little bit on low-res screens // spacing between pages in dp. To define spacing color, set view background .spacing(0) .autoSpacing(false) // add dynamic spacing to fit each page on its own on the screen .linkHandler(DefaultLinkHandler) .pageFitPolicy(FitPolicy.WIDTH) // mode to fit pages in the view .fitEachPage(false) // fit each page to the view, else smaller pages are scaled relative to largest page. .pageSnap(false) // snap pages to screen boundaries .pageFling(false) // make a fling change only a single page like ViewPager .nightMode(false) // toggle night mode .load(); ``` -------------------------------- ### Configure 16 KB Page Size in sample/build.gradle Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Apply 16 KB page size support configuration to the sample application's build.gradle file. This includes setting packaging options and the NDK version. ```gradle packagingOptions { // ... existing exclusions ... // 16 KB page size support configuration jniLibs { useLegacyPackaging false // Use uncompressed shared libraries for 16 KB alignment } } // Enable 16 KB page size support for native libraries ndkVersion "28.0.12433566" // Use NDK r28+ for 16 KB support ``` -------------------------------- ### Enable 16 KB Page Size Support in gradle.properties Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Configure Gradle properties to enable uncompressed native libraries and full R8 mode for 16 KB page size compatibility. ```properties # 16 KB page size support android.bundle.enableUncompressedNativeLibs=false android.enableR8.fullMode=true ``` -------------------------------- ### Check Device Page Size with ADB Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Use the adb shell command to verify the system's page size on a connected device. The output should be 16384 for 16 KB support. ```bash adb shell getconf PAGE_SIZE # Should return 16384 ``` -------------------------------- ### Verify 16 KB Alignment on Windows PowerShell Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Execute the provided PowerShell script to verify the 16 KB alignment of your APK on Windows. ```powershell .\check_16kb_alignment.ps1 -ApkFile "sample\build\outputs\apk\debug\sample-debug.apk" ``` -------------------------------- ### Run Realignment Script Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Execute the realignment script on a copied APK to fix potential 16 KB alignment issues. ```batch .\realign_apk.bat "sample-debug-copy.apk" ``` -------------------------------- ### Configure 16 KB Page Size in android-pdf-viewer/build.gradle Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Configure packaging options and NDK version for 16 KB page size support in the main library's build.gradle file. Ensure uncompressed shared libraries are used for proper alignment. ```gradle // 16 KB page size support configuration packagingOptions { jniLibs { useLegacyPackaging false // Use uncompressed shared libraries for 16 KB alignment } } // Enable 16 KB page size support for native libraries ndkVersion "28.0.12433566" // Use NDK r28+ for 16 KB support ``` -------------------------------- ### Manual APK Alignment Check Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Perform a manual check of APK alignment using the zipalign tool with specific flags. Ensure the APK is properly aligned for 16 KB page sizes. ```bash zipalign -c -p -v 4 your-app.apk ``` -------------------------------- ### Verify 16 KB Alignment on Windows Batch Script Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Run the provided Windows batch script to check the 16 KB alignment of your APK. ```batch .\realign_apk.bat "sample\build\outputs\apk\debug\sample-debug.apk" ``` -------------------------------- ### Fix 16 KB Page Size Alignment (Windows) Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Use this batch script on Windows to realign your APK for 16 KB page sizes if it fails the verification checks. ```batch .\realign_apk.bat "your-app.apk" ``` -------------------------------- ### Verify Realignment Fix Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md After running the realignment script, use zipalign to verify that the APK now meets the 16 KB alignment requirements. ```bash zipalign -c -p -v 4 sample-debug-copy.apk ``` -------------------------------- ### Verify 16 KB Alignment on Linux/macOS Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Use the provided shell script to check the 16 KB alignment of your APK on Linux or macOS systems. ```bash ./check_16kb_alignment.sh sample/build/outputs/apk/debug/sample-debug.apk ``` -------------------------------- ### Verify 16 KB Alignment using Python Script Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Utilize the cross-platform Python script to verify the 16 KB alignment of your APK. ```python python fix_16kb_alignment.py "sample/build/outputs/apk/debug/sample-debug.apk" ``` -------------------------------- ### Copy APK for Realignment Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/16KB_SUPPORT.md Create a copy of your APK before running realignment scripts to avoid potential file lock issues. ```bash cp sample/build/outputs/apk/debug/sample-debug.apk sample-debug-copy.apk ``` -------------------------------- ### Fit Document to Screen Width Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Renders a specific page to fit the screen width, useful for orientation changes. This should be used within the onInitiallyRendered callback. ```java Configurator.onRender(new OnRenderListener() { @Override public void onInitiallyRendered(int pages, float pageWidth, float pageHeight) { pdfView.fitToWidth(pageIndex); } }); ``` -------------------------------- ### Load PDF from Different Sources Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Shorthand methods for loading PDF documents from various sources like URI, File, byte array, InputStream, or assets. ```java pdfView.fromUri(Uri) ``` ```java pdfView.fromFile(File) ``` ```java pdfView.fromBytes(byte[]) ``` ```java pdfView.fromStream(InputStream) ``` ```java pdfView.fromAsset(String) ``` -------------------------------- ### Configure Single Page Scrolling Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Enables ViewPager-like scrolling and snapping behavior for single pages. Use these settings to achieve a smooth page-turning effect. ```java .swipeHorizontal(true) .pageSnap(true) .autoSpacing(true) .pageFling(true) ``` -------------------------------- ### Add Android PDF Viewer Dependency Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Include this dependency in your app's build.gradle file to use the library. Choose the latest beta or a stable version. ```gradle implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1' ``` ```gradle implementation 'com.github.barteksc:android-pdf-viewer:2.8.2' ``` -------------------------------- ### Set Page Fit Policy Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Configure the page fitting policy to control how pages are scaled to fit the view. Options include fitting by width, height, or both. ```java .pageFitPolicy(FitPolicy.WIDTH) ``` -------------------------------- ### ProGuard Configuration for PDF Viewer Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md If you are using ProGuard for code shrinking, add this rule to your ProGuard configuration file to prevent issues with the library. ```proguard -keep class com.shockwave.** ``` -------------------------------- ### Set Zoom Levels Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Allows customization of the minimum, mid, and maximum zoom levels for double-tap zooming. ```java void setMinZoom(float zoom); void setMidZoom(float zoom); void setMaxZoom(float zoom); ``` -------------------------------- ### Set Custom Link Handler Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Set a custom link handler to manage link behavior within the PDF document. Implement the LinkHandler interface for custom actions. ```java .linkHandler(LinkHandler) ``` -------------------------------- ### Register Default Scroll Handle Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Register the default scroll handle implementation. This can be placed on the right/bottom or left/top by providing a boolean argument to the constructor. ```java .scrollHandle(new DefaultScrollHandle(this)) ``` ```java new DefaultScrollHandle(this, true) ``` -------------------------------- ### Include PDFView in Layout Source: https://github.com/dimuthuupe/androidpdfviewer/blob/master/README.md Add the PDFView widget to your Android XML layout file to display PDF documents. It supports matching parent dimensions. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.