├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── LICENSE ├── LibPdfium ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── .gitignore │ ├── .vs │ ├── pdfium_lib │ │ └── v16 │ │ │ └── ipch │ └── pdfium_lib_android │ │ ├── v15 │ │ └── v16 │ │ └── ipch │ ├── AndroidManifest.xml │ ├── build.sh │ ├── builds │ ├── agg23 │ │ ├── agg23.vcxproj │ │ └── agg23.vcxproj.filters │ ├── agg23_android │ │ ├── agg23_android.vcxproj │ │ └── agg23_android.vcxproj.filters │ ├── fpdfsdk │ │ ├── fpdfsdk.vcxproj │ │ └── fpdfsdk.vcxproj.filters │ ├── fpdfsdk_android │ │ ├── fpdfsdk_android.vcxproj │ │ └── fpdfsdk_android.vcxproj.filters │ ├── freetype │ │ ├── freetype.vcxproj │ │ └── freetype.vcxproj.filters │ ├── freetype_android │ │ ├── freetype_android.vcxproj │ │ └── freetype_android.vcxproj.filters │ ├── fxcodec │ │ ├── fxcodec.vcxproj │ │ └── fxcodec.vcxproj.filters │ ├── fxcodec_android │ │ ├── fxcodec_android.vcxproj │ │ └── fxcodec_android.vcxproj.filters │ ├── icu │ │ ├── icu.vcxproj │ │ └── icu.vcxproj.filters │ ├── icu_android │ │ ├── icu_android.vcxproj │ │ └── icu_android.vcxproj.filters │ ├── lcms │ │ ├── lcms.vcxproj │ │ └── lcms.vcxproj.filters │ ├── lcms_android │ │ ├── lcms_android.vcxproj │ │ └── lcms_android.vcxproj.filters │ ├── libjpeg │ │ ├── libjpeg.vcxproj │ │ └── libjpeg.vcxproj.filters │ ├── libjpeg_android │ │ ├── libjpeg_android.vcxproj │ │ └── libjpeg_android.vcxproj.filters │ ├── libjpeg_turbo │ │ ├── libjpeg_turbo.vcxproj │ │ └── libjpeg_turbo.vcxproj.filters │ ├── libopenjpeg20 │ │ ├── libopenjpeg20.vcxproj │ │ └── libopenjpeg20.vcxproj.filters │ ├── libopenjpeg20_android │ │ ├── libopenjpeg20_android.vcxproj │ │ └── libopenjpeg20_android.vcxproj.filters │ ├── pdfium_base │ │ ├── pdfium_base.vcxproj │ │ └── pdfium_base.vcxproj.filters │ ├── pdfium_base_android │ │ ├── pdfium_base_android.vcxproj │ │ └── pdfium_base_android.vcxproj.filters │ ├── render_pdf │ │ ├── render_pdf.cpp │ │ ├── render_pdf.vcxproj │ │ ├── render_pdf.vcxproj.filters │ │ └── src │ │ │ ├── ProgramOptions.hxx │ │ │ ├── pdfium_aux.cpp │ │ │ ├── pdfium_aux.h │ │ │ ├── render_pdf_options.cpp │ │ │ ├── render_pdf_options.h │ │ │ └── stb_image_write.h │ ├── zlib │ │ ├── zlib.vcxproj │ │ └── zlib.vcxproj.filters │ └── zlib_android │ │ ├── zlib_android.vcxproj │ │ └── zlib_android.vcxproj.filters │ ├── cpp │ ├── CMakeLists.txt │ ├── mainJNILib.cpp │ ├── util.h │ └── utils │ │ ├── Errors.h │ │ └── Mutex.h │ ├── java │ └── com │ │ └── shockwave │ │ └── pdfium │ │ ├── PdfDocument.java │ │ ├── PdfPasswordException.java │ │ ├── PdfiumCore.java │ │ └── util │ │ ├── Size.java │ │ └── SizeF.java │ ├── makefile │ ├── pdfium_lib.mk │ ├── pdfium_lib.sln │ ├── pdfium_lib.vcxproj │ ├── pdfium_lib.vcxproj.filters │ ├── pdfium_lib_android.sln │ ├── pdfium_lib_android.vcxproj │ ├── pdfium_lib_android.vcxproj.filters │ ├── pdfiumagg23.mk │ ├── pdfiumbase.mk │ ├── pdfiumfpdfsdk.mk │ ├── pdfiumfreetype.mk │ ├── pdfiumfxcodec.mk │ ├── pdfiumicu.mk │ ├── pdfiumjpeg.mk │ ├── pdfiumjpeg_turbo.mk │ ├── pdfiumlcms.mk │ ├── pdfiumopenjpeg20.mk │ ├── pdfiumzlib.mk │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── LibPdfiumSep ├── build.gradle └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── shockwave │ │ └── pdfium │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ └── jni │ ├── Android.mk │ ├── Application.mk │ ├── include │ └── utils │ │ ├── Errors.h │ │ └── Mutex.h │ └── lib │ ├── Readme.md │ ├── arm64-v8a │ └── .keep_dir │ ├── armeabi-v7a │ └── .keep_dir │ ├── mips │ └── .keep_dir │ ├── mips64 │ └── .keep_dir │ ├── x86 │ └── .keep_dir │ └── x86_64 │ └── .keep_dir ├── PDFIUM.lnk ├── PDocViewer ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── sample.pdf │ ├── java │ └── com │ │ └── knizha │ │ └── PDocViewer │ │ ├── AnimationManager.java │ │ ├── CMN.java │ │ ├── CacheManager.java │ │ ├── DecodingAsyncTask.java │ │ ├── DragPinchManager.java │ │ ├── PDocBenchMarkctivity.java │ │ ├── PDocMainActivity.java │ │ ├── PDocView.java │ │ ├── PDocument.java │ │ ├── PagesLoader.java │ │ ├── PdfFile.java │ │ ├── RenderingHandler.java │ │ ├── exception │ │ ├── FileNotFoundException.java │ │ └── PageRenderingException.java │ │ ├── link │ │ ├── DefaultLinkHandler.java │ │ └── LinkHandler.java │ │ ├── listener │ │ ├── Callbacks.java │ │ ├── OnDrawListener.java │ │ ├── OnErrorListener.java │ │ ├── OnLoadCompleteListener.java │ │ ├── OnLongPressListener.java │ │ ├── OnPageChangeListener.java │ │ ├── OnPageErrorListener.java │ │ ├── OnPageScrollListener.java │ │ ├── OnRenderListener.java │ │ └── OnTapListener.java │ │ ├── model │ │ ├── LinkTapEvent.java │ │ └── PagePart.java │ │ ├── scroll │ │ ├── DefaultScrollHandle.java │ │ └── ScrollHandle.java │ │ ├── source │ │ ├── AssetSource.java │ │ ├── ByteArraySource.java │ │ ├── DocumentSource.java │ │ ├── FileSource.java │ │ ├── InputStreamSource.java │ │ └── UriSource.java │ │ └── util │ │ ├── ArrayUtils.java │ │ ├── Constants.java │ │ ├── FileUtils.java │ │ ├── FitPolicy.java │ │ ├── MathUtils.java │ │ ├── PageSizeCalculator.java │ │ ├── SnapEdge.java │ │ └── Util.java │ └── res │ ├── drawable-hdpi │ └── ic_open_in_browser_grey_700_48dp.png │ ├── drawable-mdpi │ └── ic_open_in_browser_grey_700_48dp.png │ ├── drawable-xhdpi │ └── ic_open_in_browser_grey_700_48dp.png │ ├── drawable-xxhdpi │ └── ic_open_in_browser_grey_700_48dp.png │ ├── drawable-xxxhdpi │ └── ic_open_in_browser_grey_700_48dp.png │ ├── drawable │ ├── default_scroll_handle_bottom.xml │ ├── default_scroll_handle_left.xml │ ├── default_scroll_handle_right.xml │ ├── default_scroll_handle_top.xml │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── menu │ └── options.xml │ └── values │ ├── attrs.xml │ ├── strings.xml │ └── styles.xml ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | build/ 3 | lint.xml 4 | bin/ 5 | gen/ 6 | .settings 7 | .project 8 | .classpath 9 | out 10 | gen-external-apklibs/ 11 | classes/ 12 | 13 | PDFIUM_A7 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Android Studio 19 | .idea/ 20 | */out 21 | !*/build/apk/ 22 | */production/ 23 | *.iws 24 | *.ipr 25 | *.iml 26 | *~ 27 | *.swp 28 | 29 | # gradle 30 | .gradle 31 | 32 | .DS_Store 33 | 34 | .cxx 35 | bk 36 | *.so 37 | *.d 38 | *.o 39 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "LibPdfium/src/main/PDFIUM"] 2 | path = LibPdfium/src/main/PDFIUM 3 | url = https://github.com/KnIfER/LibPDFium.git 4 | -------------------------------------------------------------------------------- /LibPdfium/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /LibPdfium/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | defaultConfig { 6 | minSdkVersion 19 7 | targetSdkVersion 29 8 | versionCode 1 9 | versionName "1.0" 10 | 11 | ndk { 12 | //生成相应平台.so 13 | abiFilters 'arm64-v8a' 14 | } 15 | 16 | externalNativeBuild { 17 | cmake { 18 | // Passes optional arguments to CMake. 19 | arguments '-DANDROID_PLATFORM=android-19', '-DANDROID_TOOLCHAIN=clang' 20 | 21 | // Sets optional flags for the C compiler. 22 | //cFlags "-D_EXAMPLE_C_FLAG1", "-D_EXAMPLE_C_FLAG2" 23 | 24 | // Sets a flag to enable format macro constants for the C++ compiler. 25 | cppFlags "-D__STDC_FORMAT_MACROS -DFT2_BUILD_LIBRARY" 26 | } 27 | } 28 | } 29 | 30 | // sourceSets{ 31 | // main { 32 | // jni.srcDirs = [ '../LibPdfium/src/main/jni'] 33 | // } 34 | // } 35 | 36 | buildTypes { 37 | release { 38 | minifyEnabled false 39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 40 | } 41 | } 42 | 43 | externalNativeBuild { 44 | cmake { 45 | path "src/main/cpp/CMakeLists.txt" 46 | } 47 | } 48 | } 49 | 50 | dependencies { 51 | api fileTree(dir: 'libs', include: ['*.jar']) 52 | api("androidx.appcompat:appcompat:1.1.0-rc01") 53 | } 54 | -------------------------------------------------------------------------------- /LibPdfium/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\app\AndroidSdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /LibPdfium/src/main/.vs/pdfium_lib/v16/ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/.vs/pdfium_lib/v16/ipch -------------------------------------------------------------------------------- /LibPdfium/src/main/.vs/pdfium_lib_android/v15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/.vs/pdfium_lib_android/v15 -------------------------------------------------------------------------------- /LibPdfium/src/main/.vs/pdfium_lib_android/v16/ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/.vs/pdfium_lib_android/v16/ipch -------------------------------------------------------------------------------- /LibPdfium/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LibPdfium/src/main/build.sh: -------------------------------------------------------------------------------- 1 | export ANDROID_SDK=/mnt/d/Code/NVPACK/android_sdk 2 | export PATH=$ANDROID_SDK/platform-tools:$PATH 3 | export PATH=$ANDROID_SDK/tools:$PATH 4 | 5 | export NDK=/mnt/d/Code/NVPACK/android-ndk-r21b 6 | export NDK=/mnt/d/Code/NVPACK/android_sdk/ndk/21.0.6113669 7 | 8 | export PATH=$NDK:$PATH 9 | 10 | export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64 11 | export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/windows-x86_64 12 | export SYSROOT=$TOOLCHAIN/sysroot 13 | 14 | export SYSROOTW=$NDKW/toolchains/llvm/prebuilt/windows-x86_64/sysroot 15 | 16 | export AR=$TOOLCHAIN/bin/aarch64-linux-android-ar.exe 17 | 18 | export WIN=1 19 | export NDKW=$NDK 20 | export PWDW=$PWD 21 | export SYSROOTW=$SYSROOT 22 | 23 | export arch=arm64 24 | 25 | make -j3 all -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/agg23/agg23.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/agg23_android/agg23_android.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Header Files 6 | 7 | 8 | Header Files 9 | 10 | 11 | Header Files 12 | 13 | 14 | Header Files 15 | 16 | 17 | Header Files 18 | 19 | 20 | Header Files 21 | 22 | 23 | Header Files 24 | 25 | 26 | Header Files 27 | 28 | 29 | Header Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | 53 | 54 | {7910b583-b4a2-456a-9aa5-40288acda33f} 55 | 56 | 57 | {bdbfa9b7-e1f9-488d-8d00-b8781fc9c995} 58 | 59 | 60 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/freetype_android/freetype_android.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files\base 6 | 7 | 8 | Source Files\base 9 | 10 | 11 | Source Files\base 12 | 13 | 14 | Source Files\base 15 | 16 | 17 | Source Files\base 18 | 19 | 20 | Source Files\base 21 | 22 | 23 | Source Files\base 24 | 25 | 26 | Source Files\cff 27 | 28 | 29 | Source Files\cid 30 | 31 | 32 | Source Files\psaux 33 | 34 | 35 | Source Files\pshinter 36 | 37 | 38 | Source Files\psnames 39 | 40 | 41 | Source Files\raster 42 | 43 | 44 | Source Files\sfnt 45 | 46 | 47 | Source Files\smooth 48 | 49 | 50 | Source Files\truetype 51 | 52 | 53 | Source Files\type1 54 | 55 | 56 | 57 | 58 | Header Files\base 59 | 60 | 61 | Header Files\psnames 62 | 63 | 64 | 65 | 66 | {da94b002-20ea-4442-9597-b3a6c385d2eb} 67 | 68 | 69 | {61696362-ae50-4de6-8c4e-3ce169f0f9a4} 70 | 71 | 72 | {688b0e45-4ee0-4b36-8353-17abfd1ae6d0} 73 | 74 | 75 | {63871866-16d2-4923-800f-aacc806c72cd} 76 | 77 | 78 | {d88b0e45-4ee0-4b36-8353-17abfd1ae6d0} 79 | 80 | 81 | {7096c672-ee4e-47b3-b378-52f7dc36386d} 82 | 83 | 84 | {993aa97d-b668-42d6-8917-0f511acad93c} 85 | 86 | 87 | {65e2cace-a1c2-49e2-985c-bb79462b6975} 88 | 89 | 90 | {3cfc4f15-2295-4ec7-ae11-4d100e5ef7fb} 91 | 92 | 93 | {53871866-16d2-4923-800f-aacc806c72cd} 94 | 95 | 96 | {382b6376-e24e-442f-9294-19fce179b121} 97 | 98 | 99 | {5341b366-906b-4124-9d33-a68d43fde7ca} 100 | 101 | 102 | {73c986f7-e9c1-44bd-86bf-1b959f75d895} 103 | 104 | 105 | {0190378a-98ed-4198-8c8a-a4e7a3d6038b} 106 | 107 | 108 | {8d788e88-a095-45b9-9040-68a0b33aee4a} 109 | 110 | 111 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/lcms/lcms.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | Source Files 88 | 89 | 90 | Source Files 91 | 92 | 93 | Source Files 94 | 95 | 96 | Source Files 97 | 98 | 99 | Source Files 100 | 101 | 102 | Source Files 103 | 104 | 105 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/lcms_android/lcms_android.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | Source Files 39 | 40 | 41 | Source Files 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Source Files 51 | 52 | 53 | Source Files 54 | 55 | 56 | Source Files 57 | 58 | 59 | Source Files 60 | 61 | 62 | Source Files 63 | 64 | 65 | Source Files 66 | 67 | 68 | Source Files 69 | 70 | 71 | Source Files 72 | 73 | 74 | Source Files 75 | 76 | 77 | Source Files 78 | 79 | 80 | Source Files 81 | 82 | 83 | 84 | 85 | {da94b002-20ea-4442-9597-b3a6c385d2eb} 86 | 87 | 88 | {61696362-ae50-4de6-8c4e-3ce169f0f9a4} 89 | 90 | 91 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/libopenjpeg20/libopenjpeg20.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {badd36b7-fb06-48fe-aa5c-37bd1ec64e97} 18 | 19 | 20 | 21 | 22 | Source Files\libopenjpeg20 23 | 24 | 25 | Source Files\libopenjpeg20 26 | 27 | 28 | Source Files\libopenjpeg20 29 | 30 | 31 | Source Files\libopenjpeg20 32 | 33 | 34 | Source Files\libopenjpeg20 35 | 36 | 37 | Source Files\libopenjpeg20 38 | 39 | 40 | Source Files\libopenjpeg20 41 | 42 | 43 | Source Files\libopenjpeg20 44 | 45 | 46 | Source Files\libopenjpeg20 47 | 48 | 49 | Source Files\libopenjpeg20 50 | 51 | 52 | Source Files\libopenjpeg20 53 | 54 | 55 | Source Files\libopenjpeg20 56 | 57 | 58 | Source Files\libopenjpeg20 59 | 60 | 61 | Source Files\libopenjpeg20 62 | 63 | 64 | Source Files\libopenjpeg20 65 | 66 | 67 | Source Files\libopenjpeg20 68 | 69 | 70 | Source Files\libopenjpeg20 71 | 72 | 73 | Source Files\libopenjpeg20 74 | 75 | 76 | Source Files\libopenjpeg20 77 | 78 | 79 | Source Files\libopenjpeg20 80 | 81 | 82 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/pdfium_base_android/pdfium_base_android.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | 74 | 75 | {da94b002-20ea-4442-9597-b3a6c385d2eb} 76 | 77 | 78 | {61696362-ae50-4de6-8c4e-3ce169f0f9a4} 79 | 80 | 81 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/render_pdf/render_pdf.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | src 7 | 8 | 9 | src 10 | 11 | 12 | 13 | 14 | {bf62f7c3-69d3-4779-a31a-dfa6541766ae} 15 | 16 | 17 | 18 | 19 | src 20 | 21 | 22 | src 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/render_pdf/src/pdfium_aux.cpp: -------------------------------------------------------------------------------- 1 | #include "pdfium_aux.h" 2 | #define STB_IMAGE_WRITE_IMPLEMENTATION 3 | #include "stb_image_write.h" 4 | 5 | void InitPdfium(const RenderPdfOptions& options) 6 | { 7 | FPDF_LIBRARY_CONFIG config; 8 | config.version = 2; 9 | config.m_pUserFontPaths = nullptr; 10 | config.m_pIsolate = nullptr; 11 | config.m_v8EmbedderSlot = 0; 12 | 13 | auto fd = options.fontDirectory(); 14 | if (!fd.empty()) { 15 | static const char* path_array[2]; 16 | static char buff[1024]; 17 | snprintf(buff, 1024, "%s", fd.c_str()); 18 | path_array[0] = buff; 19 | path_array[1] = nullptr; 20 | config.m_pUserFontPaths = path_array; 21 | } 22 | 23 | FPDF_InitLibraryWithConfig(&config); 24 | } 25 | 26 | ScopedFPDFBitmap RenderPage(FPDF_PAGE page, float scale) 27 | { 28 | auto width = static_cast(FPDF_GetPageWidth(page) * scale + 0.5f); 29 | auto height = static_cast(FPDF_GetPageHeight(page) * scale + 0.5f); 30 | int alpha = FPDFPage_HasTransparency(page) ? 1 : 0; 31 | ScopedFPDFBitmap bitmap(FPDFBitmap_Create(width, height, alpha)); 32 | 33 | if (!bitmap) 34 | throw std::runtime_error("unable to create bitmap."); 35 | 36 | FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF; 37 | FPDFBitmap_FillRect(bitmap.get(), 0, 0, width, height, fill_color); 38 | 39 | FPDF_RenderPageBitmap(bitmap.get(), page, 0, 0, width, height, 0, FPDF_ANNOT); 40 | return bitmap; 41 | } 42 | 43 | int GetNumChannels(FPDF_BITMAP bmp) 44 | { 45 | switch (FPDFBitmap_GetFormat(bmp)) { 46 | case FPDFBitmap_Gray: 47 | return 1; 48 | case FPDFBitmap_BGR: 49 | return 3; 50 | case FPDFBitmap_BGRx: 51 | case FPDFBitmap_BGRA: 52 | return 4; 53 | case FPDFBitmap_Unknown: 54 | return -1; 55 | } 56 | return -1; 57 | } 58 | 59 | void WriteImage(FPDF_BITMAP bitmap, ImageFormat format, const std::string& output_filename) 60 | { 61 | int result = 0; 62 | int wd = FPDFBitmap_GetWidth(bitmap); 63 | int hgt = FPDFBitmap_GetHeight(bitmap); 64 | int num_channels = GetNumChannels(bitmap); 65 | int stride = FPDFBitmap_GetStride(bitmap); 66 | auto data = FPDFBitmap_GetBuffer(bitmap); 67 | 68 | if (num_channels < 0) 69 | throw std::runtime_error("invalid bitmap format"); 70 | 71 | switch (format) { 72 | case ImageFormat::PNG: 73 | result = stbi_write_png(output_filename.c_str(), wd, hgt, num_channels, data, stride); 74 | break; 75 | case ImageFormat::BMP: 76 | result = stbi_write_bmp(output_filename.c_str(), wd, hgt, num_channels, data); 77 | break; 78 | case ImageFormat::JPEG: 79 | result = stbi_write_jpg(output_filename.c_str(), wd, hgt, num_channels, data, 85); 80 | break; 81 | } 82 | if (!result) 83 | throw std::runtime_error("Error writing iamge file."); 84 | } 85 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/render_pdf/src/pdfium_aux.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "render_pdf_options.h" 6 | #include "public/fpdfview.h" 7 | #include "public/cpp/fpdf_scopers.h" 8 | 9 | void InitPdfium(const RenderPdfOptions& options); 10 | std::string GetImageFilename(const RenderPdfOptions& options, std::optional page_number); 11 | ScopedFPDFBitmap RenderPage(FPDF_PAGE page, float scale); 12 | void WriteImage(FPDF_BITMAP bitmap, ImageFormat format, const std::string& output_filename); -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/render_pdf/src/render_pdf_options.cpp: -------------------------------------------------------------------------------- 1 | #include "render_pdf_options.h" 2 | #include "ProgramOptions.hxx" 3 | #include 4 | #include 5 | 6 | PageRange::PageRange(const std::string& range_str) 7 | { 8 | if (range_str.empty()) { 9 | _from = _to = 0; 10 | return; 11 | } 12 | 13 | if (range_str == "all") { 14 | _from = _to = -1; 15 | return; 16 | } 17 | 18 | auto dash_pos = range_str.find('-'); 19 | if (dash_pos == std::string::npos) { 20 | _from = _to = std::stoi(range_str); 21 | } 22 | 23 | int n = range_str.length(); 24 | _from = std::stoi(range_str.substr(0, dash_pos)); 25 | _to = std::stoi(range_str.substr(dash_pos+1, n-dash_pos-1)); 26 | } 27 | 28 | bool PageRange::isAll() const 29 | { 30 | return _from == -1 || _to == -1; 31 | } 32 | 33 | std::tuple PageRange::get(FPDF_DOCUMENT doc) 34 | { 35 | if (isAll()) { 36 | return { 0, FPDF_GetPageCount(doc) }; 37 | } else { 38 | return { _from, _to }; 39 | } 40 | } 41 | 42 | ImageFormat RenderPdfOptions::getImageFormat(const std::string& format_str, const std::string& output_file) const 43 | { 44 | static std::unordered_map str_to_fmt = { 45 | {"png", ImageFormat::PNG}, {"PNG", ImageFormat::PNG}, {"bmp", ImageFormat::BMP}, {"BMP", ImageFormat::BMP}, 46 | {"jpg", ImageFormat::JPEG}, {"JPG", ImageFormat::JPEG}, {"jpeg", ImageFormat::JPEG}, {"JPEG", ImageFormat::JPEG}, 47 | {".png", ImageFormat::PNG}, {".PNG", ImageFormat::PNG}, {".bmp", ImageFormat::BMP}, {".BMP", ImageFormat::BMP}, 48 | {".jpg", ImageFormat::JPEG}, {".JPG", ImageFormat::JPEG}, {".jpeg", ImageFormat::JPEG}, {".JPEG", ImageFormat::JPEG}, 49 | {"", ImageFormat::Unknown}, 50 | }; 51 | auto item = str_to_fmt.find(format_str); 52 | auto format = (item != str_to_fmt.end()) ? item->second : ImageFormat::Unknown; 53 | if (format != ImageFormat::Unknown) 54 | return format; 55 | if (output_file.empty()) 56 | return ImageFormat::PNG; 57 | auto extension = std::filesystem::path(output_file).extension().string(); 58 | if (extension.empty() || str_to_fmt.find(extension) == str_to_fmt.end()) 59 | return ImageFormat::PNG; 60 | return str_to_fmt[extension]; 61 | } 62 | 63 | std::tuple RenderPdfOptions::getOutputFile(const std::string& inp, const std::string& out, ImageFormat fmt) const 64 | { 65 | static std::unordered_map str_to_fmt = { 66 | {ImageFormat::PNG, ".png"}, 67 | {ImageFormat::BMP, ".bmp"}, 68 | {ImageFormat::JPEG, ".jpg"}, 69 | {ImageFormat::Unknown, ""} 70 | }; 71 | 72 | std::string directory, stem, extension; 73 | if (!out.empty()){ 74 | auto path = std::filesystem::path(out); 75 | directory = path.parent_path().string(); 76 | stem = path.stem().string(); 77 | extension = std::filesystem::path(out).extension().string(); 78 | extension = (!extension.empty()) ? extension : str_to_fmt[fmt]; 79 | } else { 80 | auto path = std::filesystem::path(inp); 81 | directory = path.parent_path().string(); 82 | stem = std::filesystem::path(inp).stem().string(); 83 | extension = str_to_fmt[fmt]; 84 | } 85 | return { directory, stem, extension }; 86 | } 87 | 88 | RenderPdfOptions::RenderPdfOptions(int argc, char** argv) : 89 | _image_format(ImageFormat::PNG), _scale( 1.0f) 90 | { 91 | po::parser parser; 92 | parser[""].type(po::string); 93 | parser["output-path"].abbreviation('o').description("output file path").type(po::string).fallback(""); 94 | parser["font-path"].abbreviation('t').description("font directory").type(po::string).fallback(""); 95 | parser["scale"].abbreviation('s').description("font directory").type(po::f32).fallback(1.0F); 96 | parser["format"].abbreviation('f').description("image file format").type(po::string).fallback(""); 97 | parser["page-range"].abbreviation('r').description("page range (\"all\", \"1\", \"3-6\") ").type(po::string).fallback("0"); 98 | parser["password"].abbreviation('p').description("password").type(po::string).fallback(""); 99 | 100 | try { 101 | if (!parser(argc, argv)) 102 | return; 103 | 104 | auto input_opt = parser[""].get().string; 105 | if (input_opt.empty()) 106 | return; 107 | 108 | auto output_file = parser["output-path"].get().string; 109 | _input_file = input_opt; 110 | _image_format = getImageFormat(parser["format"].get().string, output_file); 111 | std::tie(_output_file_directory, _output_file_stem, _output_file_extension) = getOutputFile(input_opt, output_file, _image_format); 112 | _scale = parser["scale"].get().f32; 113 | _range = PageRange(parser["page-range"].get().string); 114 | _font_directory = parser["font-path"].get().string; 115 | _password = parser["password"].get().string; 116 | } catch (...) { 117 | _input_file = ""; 118 | } 119 | } 120 | std::string RenderPdfOptions::fontDirectory() const 121 | { 122 | return _font_directory; 123 | } 124 | 125 | std::string RenderPdfOptions::outputFile(std::optional page_num) const 126 | { 127 | std::string path_stem = (!_output_file_directory.empty()) ? 128 | (std::filesystem::path(_output_file_directory) / _output_file_stem).string() : 129 | _output_file_stem; 130 | 131 | return (page_num.has_value()) ? 132 | path_stem + "-" + std::to_string(page_num.value()) + _output_file_extension : 133 | path_stem + _output_file_extension; 134 | } 135 | 136 | std::string RenderPdfOptions::inputFile() const 137 | { 138 | return _input_file; 139 | } 140 | std::string RenderPdfOptions::password() const 141 | { 142 | return _password; 143 | } 144 | float RenderPdfOptions::scale() const 145 | { 146 | return _scale; 147 | } 148 | PageRange RenderPdfOptions::range() const 149 | { 150 | return _range; 151 | } 152 | ImageFormat RenderPdfOptions::imageFormat() const 153 | { 154 | return _image_format; 155 | } 156 | bool RenderPdfOptions::invalid() const 157 | { 158 | return _input_file.empty(); 159 | } 160 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/render_pdf/src/render_pdf_options.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "public/fpdfview.h" 7 | 8 | enum class ImageFormat { 9 | PNG, 10 | BMP, 11 | JPEG, 12 | Unknown 13 | }; 14 | 15 | struct PageRange { 16 | 17 | public: 18 | int _from; 19 | int _to; 20 | PageRange(const std::string& range_str = ""); 21 | bool isAll() const; 22 | std::tuple get(FPDF_DOCUMENT doc); 23 | }; 24 | 25 | 26 | struct RenderPdfOptions { 27 | 28 | std::string _input_file; 29 | std::string _output_file_directory; 30 | std::string _output_file_stem; 31 | std::string _output_file_extension; 32 | float _scale; 33 | PageRange _range; 34 | ImageFormat _image_format; 35 | std::string _font_directory; 36 | std::string _password; 37 | 38 | ImageFormat getImageFormat(const std::string& format_str, const std::string& output_file) const; 39 | std::tuple getOutputFile(const std::string& inp, const std::string& out, ImageFormat fmt) const; 40 | 41 | public: 42 | RenderPdfOptions(int argc, char** argv); 43 | std::string fontDirectory() const; 44 | std::string outputFile( std::optional page_num ) const; 45 | std::string inputFile() const; 46 | std::string password() const; 47 | float scale() const; 48 | PageRange range() const; 49 | ImageFormat imageFormat() const; 50 | bool invalid() const; 51 | }; -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/zlib/zlib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | Source Files 70 | 71 | 72 | Source Files 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | Source Files 88 | 89 | 90 | Source Files 91 | 92 | 93 | Source Files 94 | 95 | 96 | Source Files 97 | 98 | 99 | Source Files 100 | 101 | 102 | Source Files 103 | 104 | 105 | Source Files 106 | 107 | 108 | Source Files 109 | 110 | 111 | Source Files 112 | 113 | 114 | Source Files 115 | 116 | 117 | Source Files 118 | 119 | 120 | -------------------------------------------------------------------------------- /LibPdfium/src/main/builds/zlib_android/zlib_android.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | Source Files 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | Source Files 39 | 40 | 41 | Source Files 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Source Files 51 | 52 | 53 | Source Files 54 | 55 | 56 | Source Files\contrib\optimizations 57 | 58 | 59 | Source Files\contrib\optimizations 60 | 61 | 62 | Source Files 63 | 64 | 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | Header Files 80 | 81 | 82 | Header Files 83 | 84 | 85 | Header Files 86 | 87 | 88 | Header Files 89 | 90 | 91 | Header Files 92 | 93 | 94 | Header Files\contrib\optimizations 95 | 96 | 97 | 98 | 99 | {da94b002-20ea-4442-9597-b3a6c385d2eb} 100 | 101 | 102 | {61696362-ae50-4de6-8c4e-3ce169f0f9a4} 103 | 104 | 105 | {d88b0e45-4ee0-4b36-8353-17abfd1ae6d0} 106 | 107 | 108 | {7096c672-ee4e-47b3-b378-52f7dc36386d} 109 | 110 | 111 | {f3d47e5e-ce56-4f88-b2aa-21eb6b2ef02f} 112 | 113 | 114 | {e99bab25-cc6f-4a09-be26-bedcea69f1e1} 115 | 116 | 117 | -------------------------------------------------------------------------------- /LibPdfium/src/main/cpp/util.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by yangl on 2017/6/9. 3 | // 4 | // 5 | 6 | #ifndef _UTIL_HPP_ 7 | #define _UTIL_HPP_ 8 | 9 | #include 10 | 11 | extern "C" { 12 | #include 13 | } 14 | 15 | #include 16 | 17 | #define JIN_PASSWORD_EXCEPTION "com/shockwave/pdfium/PdfPasswordException" 18 | #define JNI_FUNC(retType, bindClass, name) JNIEXPORT retType JNICALL Java_com_shockwave_pdfium_##bindClass##_##name 19 | #define JNI_ARGS JNIEnv *env, jobject thiz 20 | 21 | #define LOG_TAG "jniPdfium" 22 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 23 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 24 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 25 | 26 | #endif // _UTIL_HPP_ 27 | -------------------------------------------------------------------------------- /LibPdfium/src/main/cpp/utils/Errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ERRORS_H 18 | #define ANDROID_ERRORS_H 19 | 20 | #include 21 | #include 22 | 23 | namespace android { 24 | 25 | // use this type to return error codes 26 | #ifdef HAVE_MS_C_RUNTIME 27 | typedef int status_t; 28 | #else 29 | typedef int32_t status_t; 30 | #endif 31 | 32 | /* the MS C runtime lacks a few error codes */ 33 | 34 | /* 35 | * Error codes. 36 | * All error codes are negative values. 37 | */ 38 | 39 | // Win32 #defines NO_ERROR as well. It has the same value, so there's no 40 | // real conflict, though it's a bit awkward. 41 | #ifdef _WIN32 42 | # undef NO_ERROR 43 | #endif 44 | 45 | enum { 46 | OK = 0, // Everything's swell. 47 | NO_ERROR = 0, // No errors. 48 | 49 | UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value 50 | 51 | NO_MEMORY = -ENOMEM, 52 | INVALID_OPERATION = -ENOSYS, 53 | BAD_VALUE = -EINVAL, 54 | BAD_TYPE = (UNKNOWN_ERROR + 1), 55 | NAME_NOT_FOUND = -ENOENT, 56 | PERMISSION_DENIED = -EPERM, 57 | NO_INIT = -ENODEV, 58 | ALREADY_EXISTS = -EEXIST, 59 | DEAD_OBJECT = -EPIPE, 60 | FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), 61 | JPARKS_BROKE_IT = -EPIPE, 62 | #if !defined(HAVE_MS_C_RUNTIME) 63 | BAD_INDEX = -EOVERFLOW, 64 | NOT_ENOUGH_DATA = -ENODATA, 65 | WOULD_BLOCK = -EWOULDBLOCK, 66 | TIMED_OUT = -ETIMEDOUT, 67 | UNKNOWN_TRANSACTION = -EBADMSG, 68 | #else 69 | BAD_INDEX = -E2BIG, 70 | NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), 71 | WOULD_BLOCK = (UNKNOWN_ERROR + 4), 72 | TIMED_OUT = (UNKNOWN_ERROR + 5), 73 | UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), 74 | #endif 75 | FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), 76 | }; 77 | 78 | // Restore define; enumeration is in "android" namespace, so the value defined 79 | // there won't work for Win32 code in a different namespace. 80 | #ifdef _WIN32 81 | # define NO_ERROR 0L 82 | #endif 83 | 84 | }; // namespace android 85 | 86 | // --------------------------------------------------------------------------- 87 | 88 | #endif // ANDROID_ERRORS_H 89 | -------------------------------------------------------------------------------- /LibPdfium/src/main/cpp/utils/Mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBS_UTILS_MUTEX_H 18 | #define _LIBS_UTILS_MUTEX_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(HAVE_PTHREADS) 25 | # include 26 | #endif 27 | 28 | #include "Errors.h" 29 | 30 | // --------------------------------------------------------------------------- 31 | namespace android { 32 | // --------------------------------------------------------------------------- 33 | 34 | class Condition; 35 | 36 | /* 37 | * Simple mutex class. The implementation is system-dependent. 38 | * 39 | * The mutex must be unlocked by the thread that locked it. They are not 40 | * recursive, i.e. the same thread can't lock it multiple times. 41 | */ 42 | class Mutex { 43 | public: 44 | enum { 45 | PRIVATE = 0, 46 | SHARED = 1 47 | }; 48 | 49 | Mutex(); 50 | Mutex(const char* name); 51 | Mutex(int type, const char* name = NULL); 52 | ~Mutex(); 53 | 54 | // lock or unlock the mutex 55 | status_t lock(); 56 | void unlock(); 57 | 58 | // lock if possible; returns 0 on success, error otherwise 59 | status_t tryLock(); 60 | 61 | // Manages the mutex automatically. It'll be locked when Autolock is 62 | // constructed and released when Autolock goes out of scope. 63 | class Autolock { 64 | public: 65 | inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } 66 | inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } 67 | inline ~Autolock() { mLock.unlock(); } 68 | private: 69 | Mutex& mLock; 70 | }; 71 | 72 | private: 73 | friend class Condition; 74 | 75 | // A mutex cannot be copied 76 | Mutex(const Mutex&); 77 | Mutex& operator = (const Mutex&); 78 | 79 | #if defined(HAVE_PTHREADS) 80 | pthread_mutex_t mMutex; 81 | #else 82 | void _init(); 83 | void* mState; 84 | #endif 85 | }; 86 | 87 | // --------------------------------------------------------------------------- 88 | 89 | #if defined(HAVE_PTHREADS) 90 | 91 | inline Mutex::Mutex() { 92 | pthread_mutex_init(&mMutex, NULL); 93 | } 94 | inline Mutex::Mutex(__attribute__((unused)) const char* name) { 95 | pthread_mutex_init(&mMutex, NULL); 96 | } 97 | inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) { 98 | if (type == SHARED) { 99 | pthread_mutexattr_t attr; 100 | pthread_mutexattr_init(&attr); 101 | pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); 102 | pthread_mutex_init(&mMutex, &attr); 103 | pthread_mutexattr_destroy(&attr); 104 | } else { 105 | pthread_mutex_init(&mMutex, NULL); 106 | } 107 | } 108 | inline Mutex::~Mutex() { 109 | pthread_mutex_destroy(&mMutex); 110 | } 111 | inline status_t Mutex::lock() { 112 | return -pthread_mutex_lock(&mMutex); 113 | } 114 | inline void Mutex::unlock() { 115 | pthread_mutex_unlock(&mMutex); 116 | } 117 | inline status_t Mutex::tryLock() { 118 | return -pthread_mutex_trylock(&mMutex); 119 | } 120 | 121 | #endif // HAVE_PTHREADS 122 | 123 | // --------------------------------------------------------------------------- 124 | 125 | /* 126 | * Automatic mutex. Declare one of these at the top of a function. 127 | * When the function returns, it will go out of scope, and release the 128 | * mutex. 129 | */ 130 | 131 | typedef Mutex::Autolock AutoMutex; 132 | 133 | // --------------------------------------------------------------------------- 134 | }; // namespace android 135 | // --------------------------------------------------------------------------- 136 | 137 | #endif // _LIBS_UTILS_MUTEX_H 138 | -------------------------------------------------------------------------------- /LibPdfium/src/main/java/com/shockwave/pdfium/PdfDocument.java: -------------------------------------------------------------------------------- 1 | package com.shockwave.pdfium; 2 | 3 | import android.graphics.RectF; 4 | import android.os.ParcelFileDescriptor; 5 | import android.util.ArrayMap; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class PdfDocument { 12 | 13 | public static class Meta { 14 | String title; 15 | String author; 16 | String subject; 17 | String keywords; 18 | String creator; 19 | String producer; 20 | String creationDate; 21 | String modDate; 22 | 23 | public String getTitle() { 24 | return title; 25 | } 26 | 27 | public String getAuthor() { 28 | return author; 29 | } 30 | 31 | public String getSubject() { 32 | return subject; 33 | } 34 | 35 | public String getKeywords() { 36 | return keywords; 37 | } 38 | 39 | public String getCreator() { 40 | return creator; 41 | } 42 | 43 | public String getProducer() { 44 | return producer; 45 | } 46 | 47 | public String getCreationDate() { 48 | return creationDate; 49 | } 50 | 51 | public String getModDate() { 52 | return modDate; 53 | } 54 | } 55 | 56 | public static class Bookmark { 57 | private List children = new ArrayList<>(); 58 | String title; 59 | long pageIdx; 60 | long mNativePtr; 61 | 62 | public List getChildren() { 63 | return children; 64 | } 65 | 66 | public boolean hasChildren() { 67 | return !children.isEmpty(); 68 | } 69 | 70 | public String getTitle() { 71 | return title; 72 | } 73 | 74 | public long getPageIdx() { 75 | return pageIdx; 76 | } 77 | } 78 | 79 | public static class Link { 80 | private RectF bounds; 81 | private Integer destPageIdx; 82 | private String uri; 83 | 84 | public Link(RectF bounds, Integer destPageIdx, String uri) { 85 | this.bounds = bounds; 86 | this.destPageIdx = destPageIdx; 87 | this.uri = uri; 88 | } 89 | 90 | public Integer getDestPageIdx() { 91 | return destPageIdx; 92 | } 93 | 94 | public String getUri() { 95 | return uri; 96 | } 97 | 98 | public RectF getBounds() { 99 | return bounds; 100 | } 101 | } 102 | 103 | /*package*/ PdfDocument() { 104 | } 105 | 106 | /*package*/ long mNativeDocPtr; 107 | /*package*/ ParcelFileDescriptor parcelFileDescriptor; 108 | 109 | /*package*/ final Map mNativePagesPtr = new ArrayMap<>(); 110 | 111 | public boolean hasPage(int index) { 112 | return mNativePagesPtr.containsKey(index); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /LibPdfium/src/main/java/com/shockwave/pdfium/PdfPasswordException.java: -------------------------------------------------------------------------------- 1 | package com.shockwave.pdfium; 2 | 3 | import java.io.IOException; 4 | 5 | public class PdfPasswordException extends IOException { 6 | public PdfPasswordException() { 7 | super(); 8 | } 9 | 10 | public PdfPasswordException(String detailMessage) { 11 | super(detailMessage); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /LibPdfium/src/main/java/com/shockwave/pdfium/util/Size.java: -------------------------------------------------------------------------------- 1 | package com.shockwave.pdfium.util; 2 | 3 | public class Size { 4 | private final int width; 5 | private final int height; 6 | 7 | public Size(int width, int height) { 8 | this.width = width; 9 | this.height = height; 10 | } 11 | 12 | public int getWidth() { 13 | return width; 14 | } 15 | 16 | public int getHeight() { 17 | return height; 18 | } 19 | 20 | @Override 21 | public boolean equals(final Object obj) { 22 | if (obj == null) { 23 | return false; 24 | } 25 | if (this == obj) { 26 | return true; 27 | } 28 | if (obj instanceof Size) { 29 | Size other = (Size) obj; 30 | return width == other.width && height == other.height; 31 | } 32 | return false; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return width + "x" + height; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | // assuming most sizes are <2^16, doing a rotate will give us perfect hashing 43 | return height ^ ((width << (Integer.SIZE / 2)) | (width >>> (Integer.SIZE / 2))); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /LibPdfium/src/main/java/com/shockwave/pdfium/util/SizeF.java: -------------------------------------------------------------------------------- 1 | package com.shockwave.pdfium.util; 2 | 3 | public class SizeF { 4 | private final float width; 5 | private final float height; 6 | 7 | public SizeF(float width, float height) { 8 | this.width = width; 9 | this.height = height; 10 | } 11 | 12 | public float getWidth() { 13 | return width; 14 | } 15 | 16 | public float getHeight() { 17 | return height; 18 | } 19 | 20 | @Override 21 | public boolean equals(final Object obj) { 22 | if (obj == null) { 23 | return false; 24 | } 25 | if (this == obj) { 26 | return true; 27 | } 28 | if (obj instanceof SizeF) { 29 | final SizeF other = (SizeF) obj; 30 | return width == other.width && height == other.height; 31 | } 32 | return false; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return width + "x" + height; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return Float.floatToIntBits(width) ^ Float.floatToIntBits(height); 43 | } 44 | 45 | public Size toSize() { 46 | return new Size((int) width, (int) height); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /LibPdfium/src/main/makefile: -------------------------------------------------------------------------------- 1 | BASE_PATH := $(call my-dir) 2 | 3 | #_ARCH_CC_ := armv7a-linux-androideabi29-clang 4 | _ARCH_PX_ := aarch64 5 | _TARGETRI_ := aarch64-linux-android 6 | _ARCH_CC_ := $(_TARGETRI_)21-clang 7 | 8 | CC := $(TOOLCHAIN)/bin/$(_ARCH_CC_) 9 | 10 | AR := $(TOOLCHAIN)/bin/aarch64-linux-android-ar.exe 11 | 12 | 13 | ifeq ($(arch), armv7a) 14 | _ARCH_PX_ := armv7a 15 | _TARGETRI_ := armv7a-linux-androideabi 16 | _ARCH_CC_ := $(_TARGETRI_)19-clang 17 | CC := $(TOOLCHAIN)/bin/$(_ARCH_CC_) 18 | AR := $(TOOLCHAIN)/bin/arm-linux-androideabi-ar.exe 19 | endif 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | ifeq ($(WIN), 1) 28 | PWDW := $(shell echo $(PWDW) | sed -E 's/^\/mnt\/([a-z])/\1:/g') 29 | NDKW := $(shell echo $(NDKW) | sed -E 's/^\/mnt\/([a-z])/\1:/g') 30 | SYSROOTW := $(shell echo $(SYSROOTW) | sed -E 's/^\/mnt\/([a-z])/\1:/g') 31 | endif 32 | 33 | # libpdfiumjpeg.a libpdfiumjpeg_turbo.a 34 | 35 | # libpdfiumfxcodec.a\ 36 | 37 | pdfium_3rd_libs = \ 38 | \ 39 | \ 40 | libpdfium_lib.a\ 41 | libpdfiumfxcodec.a\ 42 | \ 43 | libpdfiumfreetype.a\ 44 | libpdfiumzlib.a\ 45 | libpdfiumopenjpeg20.a\ 46 | libpdfiumlcms.a\ 47 | libpdfiumicu.a\ 48 | libpdfiumagg23.a\ 49 | libpdfiumjpeg.a\ 50 | 51 | 52 | pdfiumlibs = \ 53 | libpdfiumbase.a\ 54 | 55 | pdfium_libs = \ 56 | $(pdfium_3rd_libs)\ 57 | $(pdfiumlibs)\ 58 | 59 | include pdfiumzlib.mk 60 | include pdfiumopenjpeg20.mk 61 | include pdfiumicu.mk 62 | # include pdfiumbigint.mk 63 | include pdfiumagg23.mk 64 | include pdfiumlcms.mk 65 | include pdfiumfreetype.mk 66 | include pdfiumjpeg_turbo.mk 67 | include pdfiumjpeg.mk 68 | 69 | include pdfiumfxcodec.mk 70 | include pdfiumbase.mk 71 | include pdfium_lib.mk 72 | 73 | include pdfiumfpdfsdk.mk 74 | 75 | all: \ 76 | $(pdfium_libs)\ 77 | libpdfium.so\ 78 | 79 | # libpdfium.a 80 | 81 | 82 | 83 | 84 | clean : 85 | rm -f *.a 86 | rm -rf build/aarch64 87 | -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumagg23.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumagg23 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DADLER32_SIMD_NEON -DARMV8_OS_ANDROID -DINFLATE_CHUNK_SIMD_NEON -DINFLATE_CHUNK_READ_64LE 17 | 18 | LOCAL_SRC_FILES := \ 19 | pdfium/third_party/agg23/agg_curves.cpp \ 20 | pdfium/third_party/agg23/agg_path_storage.cpp \ 21 | pdfium/third_party/agg23/agg_rasterizer_scanline_aa.cpp \ 22 | pdfium/third_party/agg23/agg_vcgen_dash.cpp \ 23 | pdfium/third_party/agg23/agg_vcgen_stroke.cpp \ 24 | 25 | LOCAL_C_INCLUDES := \ 26 | -I$(PWDW)/pdfium/third_party/agg23/ \ 27 | -I$(PWDW)/pdfium/third_party/agg23/contrib\optimizations \ 28 | -I$(NDKW)/sources/android/cpufeatures \ 29 | 30 | include $(BUILD_STATIC_LIBRARY) 31 | 32 | OBJS_pdfiumagg23 := $(addsuffix .o, $(LOCAL_SRC_FILES)) 33 | OBJS_pdfiumagg23 := $(addprefix build/$(_ARCH_PX_)/pdfiumagg23/, $(OBJS_pdfiumagg23)) 34 | 35 | libpdfiumagg23.a: $(OBJS_pdfiumagg23) 36 | $(AR) -rv libpdfiumagg23.a $(OBJS_pdfiumagg23) 37 | 38 | build/$(_ARCH_PX_)/pdfiumagg23/%.o: % 39 | @echo $<; set -x;\ 40 | mkdir -p $(dir $@);\ 41 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 42 | @echo "" 43 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumbase.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumbase 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter 16 | 17 | LOCAL_SRC_FILES := \ 18 | pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.cc \ 19 | pdfium/third_party/base/allocator/partition_allocator/oom_callback.cc \ 20 | pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc \ 21 | pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc \ 22 | pdfium/third_party/base/allocator/partition_allocator/partition_bucket.cc \ 23 | pdfium/third_party/base/allocator/partition_allocator/partition_oom.cc \ 24 | pdfium/third_party/base/allocator/partition_allocator/partition_page.cc \ 25 | pdfium/third_party/base/allocator/partition_allocator/partition_root_base.cc \ 26 | pdfium/third_party/base/allocator/partition_allocator/random.cc \ 27 | pdfium/third_party/base/allocator/partition_allocator/spin_lock.cc \ 28 | pdfium/third_party/base/debug/alias.cc \ 29 | 30 | 31 | 32 | LOCAL_C_INCLUDES := \ 33 | -I$(PWDW)/pdfium/ \ 34 | 35 | 36 | include $(BUILD_STATIC_LIBRARY) 37 | 38 | OBJS_pdfiumbase := $(addsuffix .o, $(LOCAL_SRC_FILES)) 39 | OBJS_pdfiumbase := $(addprefix build/$(_ARCH_PX_)/pdfiumbase/, $(OBJS_pdfiumbase)) 40 | 41 | libpdfiumbase.a: $(OBJS_pdfiumbase) 42 | $(AR) -rv libpdfiumbase.a $(OBJS_pdfiumbase) 43 | 44 | build/$(_ARCH_PX_)/pdfiumbase/%.o: % 45 | @echo $<; set -x;\ 46 | mkdir -p $(dir $@);\ 47 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 48 | @echo "" 49 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumfpdfsdk.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumfpdfsdk 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DCOMPONENT_BUILD -DFPDF_IMPLEMENTATION -DFPDFSDK_EXPORTS -DANDROID 17 | 18 | LOCAL_SRC_FILES := \ 19 | pdfium/fpdfsdk/cpdfsdk_actionhandler.cpp \ 20 | pdfium/fpdfsdk/cpdfsdk_annot.cpp \ 21 | pdfium/fpdfsdk/cpdfsdk_annothandlermgr.cpp \ 22 | pdfium/fpdfsdk/cpdfsdk_annotiteration.cpp \ 23 | pdfium/fpdfsdk/cpdfsdk_annotiterator.cpp \ 24 | pdfium/fpdfsdk/cpdfsdk_appstream.cpp \ 25 | pdfium/fpdfsdk/cpdfsdk_baannot.cpp \ 26 | pdfium/fpdfsdk/cpdfsdk_baannothandler.cpp \ 27 | pdfium/fpdfsdk/cpdfsdk_customaccess.cpp \ 28 | pdfium/fpdfsdk/cpdfsdk_fieldaction.cpp \ 29 | pdfium/fpdfsdk/cpdfsdk_filewriteadapter.cpp \ 30 | pdfium/fpdfsdk/cpdfsdk_formfillenvironment.cpp \ 31 | pdfium/fpdfsdk/cpdfsdk_helpers.cpp \ 32 | pdfium/fpdfsdk/cpdfsdk_interactiveform.cpp \ 33 | pdfium/fpdfsdk/cpdfsdk_pageview.cpp \ 34 | pdfium/fpdfsdk/cpdfsdk_pauseadapter.cpp \ 35 | pdfium/fpdfsdk/cpdfsdk_renderpage.cpp \ 36 | pdfium/fpdfsdk/cpdfsdk_widget.cpp \ 37 | pdfium/fpdfsdk/cpdfsdk_widgethandler.cpp \ 38 | pdfium/fpdfsdk/fpdf_annot.cpp \ 39 | pdfium/fpdfsdk/fpdf_attachment.cpp \ 40 | pdfium/fpdfsdk/fpdf_catalog.cpp \ 41 | pdfium/fpdfsdk/fpdf_dataavail.cpp \ 42 | pdfium/fpdfsdk/fpdf_doc.cpp \ 43 | pdfium/fpdfsdk/fpdf_editimg.cpp \ 44 | pdfium/fpdfsdk/fpdf_editpage.cpp \ 45 | pdfium/fpdfsdk/fpdf_editpath.cpp \ 46 | pdfium/fpdfsdk/fpdf_edittext.cpp \ 47 | pdfium/fpdfsdk/fpdf_ext.cpp \ 48 | pdfium/fpdfsdk/fpdf_flatten.cpp \ 49 | pdfium/fpdfsdk/fpdf_formfill.cpp \ 50 | pdfium/fpdfsdk/fpdf_javascript.cpp \ 51 | pdfium/fpdfsdk/fpdf_ppo.cpp \ 52 | pdfium/fpdfsdk/fpdf_progressive.cpp \ 53 | pdfium/fpdfsdk/fpdf_save.cpp \ 54 | pdfium/fpdfsdk/fpdf_searchex.cpp \ 55 | pdfium/fpdfsdk/fpdf_structtree.cpp \ 56 | pdfium/fpdfsdk/fpdf_sysfontinfo.cpp \ 57 | pdfium/fpdfsdk/fpdf_text.cpp \ 58 | pdfium/fpdfsdk/fpdf_thumbnail.cpp \ 59 | pdfium/fpdfsdk/fpdf_transformpage.cpp \ 60 | pdfium/fpdfsdk/fpdf_view.cpp \ 61 | \ 62 | pdfium/fpdfsdk/formfiller/cffl_button.cpp \ 63 | pdfium/fpdfsdk/formfiller/cffl_checkbox.cpp \ 64 | pdfium/fpdfsdk/formfiller/cffl_combobox.cpp \ 65 | pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp \ 66 | pdfium/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp \ 67 | pdfium/fpdfsdk/formfiller/cffl_listbox.cpp \ 68 | pdfium/fpdfsdk/formfiller/cffl_pushbutton.cpp \ 69 | pdfium/fpdfsdk/formfiller/cffl_radiobutton.cpp \ 70 | pdfium/fpdfsdk/formfiller/cffl_textfield.cpp \ 71 | pdfium/fpdfsdk/formfiller/cffl_textobject.cpp \ 72 | \ 73 | pdfium/fpdfsdk/pwl/cpwl_button.cpp \ 74 | pdfium/fpdfsdk/pwl/cpwl_caret.cpp \ 75 | pdfium/fpdfsdk/pwl/cpwl_combo_box.cpp \ 76 | pdfium/fpdfsdk/pwl/cpwl_edit.cpp \ 77 | pdfium/fpdfsdk/pwl/cpwl_edit_ctrl.cpp \ 78 | pdfium/fpdfsdk/pwl/cpwl_edit_impl.cpp \ 79 | pdfium/fpdfsdk/pwl/cpwl_icon.cpp \ 80 | pdfium/fpdfsdk/pwl/cpwl_list_box.cpp \ 81 | pdfium/fpdfsdk/pwl/cpwl_list_impl.cpp \ 82 | pdfium/fpdfsdk/pwl/cpwl_scroll_bar.cpp \ 83 | pdfium/fpdfsdk/pwl/cpwl_special_button.cpp \ 84 | pdfium/fpdfsdk/pwl/cpwl_wnd.cpp \ 85 | \ 86 | \ 87 | \ 88 | \ 89 | 90 | 91 | 92 | LOCAL_C_INCLUDES := \ 93 | -I$(PWDW)/pdfium/ \ 94 | -I$(PWDW)/pdfium/third_party/icu/source/i18n/ \ 95 | -I$(PWDW)/pdfium/third_party/icu/source/common/ \ 96 | -I$(PWDW)/pdfium/third_party/freetype/src/include \ 97 | 98 | include $(BUILD_STATIC_LIBRARY) 99 | 100 | OBJS_pdfiumfpdfsdk := $(addsuffix .o, $(LOCAL_SRC_FILES)) 101 | OBJS_pdfiumfpdfsdk := $(addprefix build/$(_ARCH_PX_)/pdfiumfpdfsdk/, $(OBJS_pdfiumfpdfsdk)) 102 | 103 | 104 | # libpdfium.a: $(OBJS_pdfiumfpdfsdk) 105 | # $(AR) -rv libpdfium.a $(OBJS_pdfiumfpdfsdk) 106 | 107 | # libpdfium.so: $(OBJS_pdfiumfpdfsdk) $(pdfium_libs) 108 | # $(CC)++ -fPIC -shared -Wl,-soname,libpdfium.so -o libpdfium.so $(LOCAL_SRC_FILES) $(pdflibs_) -I"../" $(LOCAL_C_INCLUDES) $(pdfium_libs) 109 | 110 | libpdfium.so: $(OBJS_pdfiumfpdfsdk) $(pdfium_libs) 111 | $(CC)++ -fPIC -shared -Wl,-soname,libpdfium.so -o libpdfium.so \ 112 | -Wl,--whole-archive $(OBJS_pdfiumfpdfsdk) $(pdfiumlibs) \ 113 | -Wl,--no-whole-archive $(pdfium_3rd_libs) \ 114 | -I"../" $(LOCAL_C_INCLUDES) 115 | 116 | 117 | build/$(_ARCH_PX_)/pdfiumfpdfsdk/%.o: % 118 | @echo $<; set -x;\ 119 | mkdir -p $(dir $@);\ 120 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 121 | @echo "" 122 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumfreetype.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumfreetype 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DFT2_BUILD_LIBRARY 17 | 18 | LOCAL_SRC_FILES := \ 19 | pdfium/third_party/freetype/src/src/base/ftbase.c \ 20 | pdfium/third_party/freetype/src/src/base/ftbitmap.c \ 21 | pdfium/third_party/freetype/src/src/base/ftdebug.c \ 22 | pdfium/third_party/freetype/src/src/base/ftglyph.c \ 23 | pdfium/third_party/freetype/src/src/base/ftinit.c \ 24 | pdfium/third_party/freetype/src/src/base/ftmm.c \ 25 | pdfium/third_party/freetype/src/src/base/ftsystem.c \ 26 | pdfium/third_party/freetype/src/src/cff/cff.c \ 27 | pdfium/third_party/freetype/src/src/cid/type1cid.c \ 28 | pdfium/third_party/freetype/src/src/psaux/psaux.c \ 29 | pdfium/third_party/freetype/src/src/pshinter/pshinter.c \ 30 | pdfium/third_party/freetype/src/src/psnames/psmodule.c \ 31 | pdfium/third_party/freetype/src/src/raster/raster.c \ 32 | pdfium/third_party/freetype/src/src/sfnt/sfnt.c \ 33 | pdfium/third_party/freetype/src/src/smooth/smooth.c \ 34 | pdfium/third_party/freetype/src/src/truetype/truetype.c \ 35 | pdfium/third_party/freetype/src/src/type1/type1.c \ 36 | 37 | 38 | 39 | LOCAL_C_INCLUDES := \ 40 | -I$(PWDW)/pdfium/third_party/freetype/ \ 41 | -I$(PWDW)/pdfium/third_party/freetype/include \ 42 | -I$(PWDW)/pdfium/third_party/freetype/src/include \ 43 | -I$(PWDW)/pdfium/third_party/freetype/src/include/freetype \ 44 | -I$(PWDW)/pdfium/third_party/freetype/src/include/freetype/internal \ 45 | -I$(PWDW)/pdfium/third_party/freetype/src/include/freetype/internal/services \ 46 | -I$(PWDW)/pdfium/third_party/freetype/src/src/ \ 47 | -I$(PWDW)/pdfium/third_party/freetype/src/src/base \ 48 | -I$(PWDW)/pdfium/third_party/freetype/src/src/cff \ 49 | 50 | 51 | include $(BUILD_STATIC_LIBRARY) 52 | 53 | OBJS_pdfiumfreetype := $(addsuffix .o, $(LOCAL_SRC_FILES)) 54 | OBJS_pdfiumfreetype := $(addprefix build/$(_ARCH_PX_)/pdfiumfreetype/, $(OBJS_pdfiumfreetype)) 55 | 56 | libpdfiumfreetype.a: $(OBJS_pdfiumfreetype) 57 | $(AR) -rv libpdfiumfreetype.a $(OBJS_pdfiumfreetype) 58 | 59 | build/$(_ARCH_PX_)/pdfiumfreetype/%.o: % 60 | @echo $<; set -x;\ 61 | mkdir -p $(dir $@);\ 62 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 63 | @echo "" 64 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumfxcodec.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumfxcodec 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter -DANDROID 16 | 17 | LOCAL_SRC_FILES := \ 18 | pdfium/core/fxcodec/basic/basicmodule.cpp \ 19 | pdfium/core/fxcodec/cfx_codec_memory.cpp \ 20 | pdfium/core/fxcodec/fax/faxmodule.cpp \ 21 | pdfium/core/fxcodec/flate/flatemodule.cpp \ 22 | pdfium/core/fxcodec/fx_codec.cpp \ 23 | pdfium/core/fxcodec/icc/iccmodule.cpp \ 24 | pdfium/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp \ 25 | pdfium/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp \ 26 | pdfium/core/fxcodec/jbig2/JBig2_BitStream.cpp \ 27 | pdfium/core/fxcodec/jbig2/JBig2_Context.cpp \ 28 | pdfium/core/fxcodec/jbig2/JBig2_DocumentContext.cpp \ 29 | pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp \ 30 | pdfium/core/fxcodec/jbig2/JBig2_GrrdProc.cpp \ 31 | pdfium/core/fxcodec/jbig2/JBig2_HtrdProc.cpp \ 32 | pdfium/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp \ 33 | pdfium/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp \ 34 | pdfium/core/fxcodec/jbig2/JBig2_Image.cpp \ 35 | pdfium/core/fxcodec/jbig2/JBig2_PatternDict.cpp \ 36 | pdfium/core/fxcodec/jbig2/JBig2_PddProc.cpp \ 37 | pdfium/core/fxcodec/jbig2/JBig2_SddProc.cpp \ 38 | pdfium/core/fxcodec/jbig2/JBig2_Segment.cpp \ 39 | pdfium/core/fxcodec/jbig2/JBig2_SymbolDict.cpp \ 40 | pdfium/core/fxcodec/jbig2/JBig2_TrdProc.cpp \ 41 | pdfium/core/fxcodec/jbig2/jbig2module.cpp \ 42 | pdfium/core/fxcodec/jpeg/jpegmodule.cpp \ 43 | pdfium/core/fxcodec/jpx/cjpx_decoder.cpp \ 44 | pdfium/core/fxcodec/jpx/jpx_decode_utils.cpp \ 45 | pdfium/core/fxcodec/jpx/jpxmodule.cpp \ 46 | pdfium/core/fxcodec/scanlinedecoder.cpp \ 47 | 48 | 49 | 50 | LOCAL_C_INCLUDES := \ 51 | -I$(PWDW)/pdfium/ \ 52 | -I$(PWDW)/pdfium/third_party/icu/source/i18n/ \ 53 | -I$(PWDW)/pdfium/third_party/icu/source/common/ \ 54 | 55 | include $(BUILD_STATIC_LIBRARY) 56 | 57 | OBJS_pdfiumfxcodec := $(addsuffix .o, $(LOCAL_SRC_FILES)) 58 | OBJS_pdfiumfxcodec := $(addprefix build/$(_ARCH_PX_)/pdfiumfxcodec/, $(OBJS_pdfiumfxcodec)) 59 | 60 | libpdfiumfxcodec.a: $(OBJS_pdfiumfxcodec) 61 | $(AR) -rv libpdfiumfxcodec.a $(OBJS_pdfiumfxcodec) 62 | 63 | build/$(_ARCH_PX_)/pdfiumfxcodec/%.o: % 64 | @echo $<; set -x;\ 65 | mkdir -p $(dir $@);\ 66 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 67 | @echo "" 68 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumjpeg.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumzlib 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter -D_FX_OS_=1 16 | 17 | LOCAL_SRC_FILES := \ 18 | pdfium/third_party/libjpeg/fpdfapi_jcapimin.c \ 19 | pdfium/third_party/libjpeg/fpdfapi_jcapistd.c \ 20 | pdfium/third_party/libjpeg/fpdfapi_jccoefct.c \ 21 | pdfium/third_party/libjpeg/fpdfapi_jccolor.c \ 22 | pdfium/third_party/libjpeg/fpdfapi_jcdctmgr.c \ 23 | pdfium/third_party/libjpeg/fpdfapi_jchuff.c \ 24 | pdfium/third_party/libjpeg/fpdfapi_jcinit.c \ 25 | pdfium/third_party/libjpeg/fpdfapi_jcmainct.c \ 26 | pdfium/third_party/libjpeg/fpdfapi_jcmarker.c \ 27 | pdfium/third_party/libjpeg/fpdfapi_jcmaster.c \ 28 | pdfium/third_party/libjpeg/fpdfapi_jcomapi.c \ 29 | pdfium/third_party/libjpeg/fpdfapi_jcparam.c \ 30 | pdfium/third_party/libjpeg/fpdfapi_jcphuff.c \ 31 | pdfium/third_party/libjpeg/fpdfapi_jcprepct.c \ 32 | pdfium/third_party/libjpeg/fpdfapi_jcsample.c \ 33 | pdfium/third_party/libjpeg/fpdfapi_jctrans.c \ 34 | pdfium/third_party/libjpeg/fpdfapi_jdapimin.c \ 35 | pdfium/third_party/libjpeg/fpdfapi_jdapistd.c \ 36 | pdfium/third_party/libjpeg/fpdfapi_jdcoefct.c \ 37 | pdfium/third_party/libjpeg/fpdfapi_jdcolor.c \ 38 | pdfium/third_party/libjpeg/fpdfapi_jddctmgr.c \ 39 | pdfium/third_party/libjpeg/fpdfapi_jdhuff.c \ 40 | pdfium/third_party/libjpeg/fpdfapi_jdinput.c \ 41 | pdfium/third_party/libjpeg/fpdfapi_jdmainct.c \ 42 | pdfium/third_party/libjpeg/fpdfapi_jdmarker.c \ 43 | pdfium/third_party/libjpeg/fpdfapi_jdmaster.c \ 44 | pdfium/third_party/libjpeg/fpdfapi_jdmerge.c \ 45 | pdfium/third_party/libjpeg/fpdfapi_jdphuff.c \ 46 | pdfium/third_party/libjpeg/fpdfapi_jdpostct.c \ 47 | pdfium/third_party/libjpeg/fpdfapi_jdsample.c \ 48 | pdfium/third_party/libjpeg/fpdfapi_jdtrans.c \ 49 | pdfium/third_party/libjpeg/fpdfapi_jerror.c \ 50 | pdfium/third_party/libjpeg/fpdfapi_jfdctfst.c \ 51 | pdfium/third_party/libjpeg/fpdfapi_jfdctint.c \ 52 | pdfium/third_party/libjpeg/fpdfapi_jidctfst.c \ 53 | pdfium/third_party/libjpeg/fpdfapi_jidctint.c \ 54 | pdfium/third_party/libjpeg/fpdfapi_jidctred.c \ 55 | pdfium/third_party/libjpeg/fpdfapi_jmemmgr.c \ 56 | pdfium/third_party/libjpeg/fpdfapi_jmemnobs.c \ 57 | pdfium/third_party/libjpeg/fpdfapi_jutils.c \ 58 | 59 | 60 | 61 | LOCAL_C_INCLUDES := \ 62 | -I$(PWDW)/pdfium/ \ 63 | -I$(PWDW)/pdfium/third_party/libjpeg/ \ 64 | 65 | 66 | include $(BUILD_STATIC_LIBRARY) 67 | 68 | OBJS_pdfiumjpeg := $(addsuffix .o, $(LOCAL_SRC_FILES)) 69 | OBJS_pdfiumjpeg := $(addprefix build/$(_ARCH_PX_)/pdfiumjpeg/, $(OBJS_pdfiumjpeg)) 70 | 71 | libpdfiumjpeg.a: $(OBJS_pdfiumjpeg) 72 | $(AR) -rv libpdfiumjpeg.a $(OBJS_pdfiumjpeg) 73 | 74 | build/$(_ARCH_PX_)/pdfiumjpeg/%.o: % 75 | @echo $<; set -x;\ 76 | mkdir -p $(dir $@);\ 77 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 78 | @echo "" 79 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumjpeg_turbo.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumjpeg_turbo 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DELF -DWITH_SIMD -DNO_GETENV 17 | 18 | LOCAL_SRC_FILES := \ 19 | pdfium/third_party/libjpeg_turbo/simd/arm/arm64/jsimd.c \ 20 | pdfium/third_party/libjpeg_turbo/simd/arm/arm64/jsimd_neon.S \ 21 | \ 22 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jdcolor-neon.c \ 23 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jdmerge-neon.c \ 24 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jdsample-neon.c \ 25 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jidctfst-neon.c \ 26 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jidctint-neon.c \ 27 | pdfium/third_party/libjpeg_turbo/simd/arm/common/jidctred-neon.c \ 28 | \ 29 | pdfium/third_party/libjpeg_turbo/jcapimin.c \ 30 | pdfium/third_party/libjpeg_turbo/jcapistd.c \ 31 | pdfium/third_party/libjpeg_turbo/jccoefct.c \ 32 | pdfium/third_party/libjpeg_turbo/jccolor.c \ 33 | pdfium/third_party/libjpeg_turbo/jcdctmgr.c \ 34 | pdfium/third_party/libjpeg_turbo/jchuff.c \ 35 | pdfium/third_party/libjpeg_turbo/jcicc.c \ 36 | pdfium/third_party/libjpeg_turbo/jcinit.c \ 37 | pdfium/third_party/libjpeg_turbo/jcmainct.c \ 38 | pdfium/third_party/libjpeg_turbo/jcmarker.c \ 39 | pdfium/third_party/libjpeg_turbo/jcmaster.c \ 40 | pdfium/third_party/libjpeg_turbo/jcomapi.c \ 41 | pdfium/third_party/libjpeg_turbo/jcparam.c \ 42 | pdfium/third_party/libjpeg_turbo/jcphuff.c \ 43 | pdfium/third_party/libjpeg_turbo/jcprepct.c \ 44 | pdfium/third_party/libjpeg_turbo/jcsample.c \ 45 | pdfium/third_party/libjpeg_turbo/jctrans.c \ 46 | pdfium/third_party/libjpeg_turbo/jdapimin.c \ 47 | pdfium/third_party/libjpeg_turbo/jdapistd.c \ 48 | pdfium/third_party/libjpeg_turbo/jdatadst.c \ 49 | pdfium/third_party/libjpeg_turbo/jdatasrc.c \ 50 | pdfium/third_party/libjpeg_turbo/jdcoefct.c \ 51 | pdfium/third_party/libjpeg_turbo/jdcolor.c \ 52 | pdfium/third_party/libjpeg_turbo/jddctmgr.c \ 53 | pdfium/third_party/libjpeg_turbo/jdhuff.c \ 54 | pdfium/third_party/libjpeg_turbo/jdicc.c \ 55 | pdfium/third_party/libjpeg_turbo/jdinput.c \ 56 | pdfium/third_party/libjpeg_turbo/jdmainct.c \ 57 | pdfium/third_party/libjpeg_turbo/jdmarker.c \ 58 | pdfium/third_party/libjpeg_turbo/jdmaster.c \ 59 | pdfium/third_party/libjpeg_turbo/jdmerge.c \ 60 | pdfium/third_party/libjpeg_turbo/jdphuff.c \ 61 | pdfium/third_party/libjpeg_turbo/jdpostct.c \ 62 | pdfium/third_party/libjpeg_turbo/jdsample.c \ 63 | pdfium/third_party/libjpeg_turbo/jdtrans.c \ 64 | pdfium/third_party/libjpeg_turbo/jerror.c \ 65 | pdfium/third_party/libjpeg_turbo/jfdctflt.c \ 66 | pdfium/third_party/libjpeg_turbo/jfdctfst.c \ 67 | pdfium/third_party/libjpeg_turbo/jfdctint.c \ 68 | pdfium/third_party/libjpeg_turbo/jidctflt.c \ 69 | pdfium/third_party/libjpeg_turbo/jidctfst.c \ 70 | pdfium/third_party/libjpeg_turbo/jidctint.c \ 71 | pdfium/third_party/libjpeg_turbo/jidctred.c \ 72 | pdfium/third_party/libjpeg_turbo/jmemmgr.c \ 73 | pdfium/third_party/libjpeg_turbo/jmemnobs.c \ 74 | pdfium/third_party/libjpeg_turbo/jpeg_nbits_table.c \ 75 | pdfium/third_party/libjpeg_turbo/jquant1.c \ 76 | pdfium/third_party/libjpeg_turbo/jquant2.c \ 77 | pdfium/third_party/libjpeg_turbo/jutils.c \ 78 | 79 | 80 | 81 | LOCAL_C_INCLUDES := \ 82 | -I$(PWDW)/pdfium/third_party/libjpeg_turbo/ \ 83 | 84 | include $(BUILD_STATIC_LIBRARY) 85 | 86 | OBJS_pdfiumjpeg_turbo := $(addsuffix .o, $(LOCAL_SRC_FILES)) 87 | OBJS_pdfiumjpeg_turbo := $(addprefix build/$(_ARCH_PX_)/pdfiumjpeg_turbo/, $(OBJS_pdfiumjpeg_turbo)) 88 | 89 | libpdfiumjpeg_turbo.a: $(OBJS_pdfiumjpeg_turbo) 90 | $(AR) -rv libpdfiumjpeg_turbo.a $(OBJS_pdfiumjpeg_turbo) 91 | 92 | # build/$(_ARCH_PX_)/pdfiumjpeg_turbo/pdfium/third_party/libjpeg_turbo/simd/arm/arm64/jsimd_neon.S.o: pdfium/third_party/libjpeg_turbo/simd/arm/arm64/jsimd_neon.S 93 | # $(NDK)/nasm.exe $< 94 | 95 | 96 | build/$(_ARCH_PX_)/pdfiumjpeg_turbo/%.o: % 97 | @echo $<; set -x;\ 98 | mkdir -p $(dir $@);\ 99 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 100 | @echo "" 101 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumlcms.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumzlib 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DADLER32_SIMD_NEON -DARMV8_OS_ANDROID -DINFLATE_CHUNK_SIMD_NEON -DINFLATE_CHUNK_READ_64LE 17 | 18 | LOCAL_SRC_FILES := \ 19 | pdfium/third_party/lcms/src/cmsalpha.c \ 20 | pdfium/third_party/lcms/src/cmscam02.c \ 21 | pdfium/third_party/lcms/src/cmscgats.c \ 22 | pdfium/third_party/lcms/src/cmscnvrt.c \ 23 | pdfium/third_party/lcms/src/cmserr.c \ 24 | pdfium/third_party/lcms/src/cmsgamma.c \ 25 | pdfium/third_party/lcms/src/cmsgmt.c \ 26 | pdfium/third_party/lcms/src/cmshalf.c \ 27 | pdfium/third_party/lcms/src/cmsintrp.c \ 28 | pdfium/third_party/lcms/src/cmsio0.c \ 29 | pdfium/third_party/lcms/src/cmsio1.c \ 30 | pdfium/third_party/lcms/src/cmslut.c \ 31 | pdfium/third_party/lcms/src/cmsmd5.c \ 32 | pdfium/third_party/lcms/src/cmsmtrx.c \ 33 | pdfium/third_party/lcms/src/cmsnamed.c \ 34 | pdfium/third_party/lcms/src/cmsopt.c \ 35 | pdfium/third_party/lcms/src/cmspack.c \ 36 | pdfium/third_party/lcms/src/cmspcs.c \ 37 | pdfium/third_party/lcms/src/cmsplugin.c \ 38 | pdfium/third_party/lcms/src/cmsps2.c \ 39 | pdfium/third_party/lcms/src/cmssamp.c \ 40 | pdfium/third_party/lcms/src/cmssm.c \ 41 | pdfium/third_party/lcms/src/cmstypes.c \ 42 | pdfium/third_party/lcms/src/cmsvirt.c \ 43 | pdfium/third_party/lcms/src/cmswtpnt.c \ 44 | pdfium/third_party/lcms/src/cmsxform.c \ 45 | 46 | 47 | 48 | LOCAL_C_INCLUDES := \ 49 | -I$(PWDW)/pdfium/ \ 50 | -I$(PWDW)/pdfium/third_party/lcms/ \ 51 | -I$(PWDW)/pdfium/third_party/lcms/include \ 52 | 53 | 54 | include $(BUILD_STATIC_LIBRARY) 55 | 56 | OBJS_pdfiumlcms := $(addsuffix .o, $(LOCAL_SRC_FILES)) 57 | OBJS_pdfiumlcms := $(addprefix build/$(_ARCH_PX_)/pdfiumlcms/, $(OBJS_pdfiumlcms)) 58 | 59 | libpdfiumlcms.a: $(OBJS_pdfiumlcms) 60 | $(AR) -rv libpdfiumlcms.a $(OBJS_pdfiumlcms) 61 | 62 | build/$(_ARCH_PX_)/pdfiumlcms/%.o: % 63 | @echo $<; set -x;\ 64 | mkdir -p $(dir $@);\ 65 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 66 | @echo "" 67 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumopenjpeg20.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumzlib 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter 16 | 17 | LOCAL_SRC_FILES := \ 18 | pdfium/third_party/libopenjpeg20/bio.c \ 19 | pdfium/third_party/libopenjpeg20/cio.c \ 20 | pdfium/third_party/libopenjpeg20/dwt.c \ 21 | pdfium/third_party/libopenjpeg20/event.c \ 22 | pdfium/third_party/libopenjpeg20/function_list.c \ 23 | pdfium/third_party/libopenjpeg20/image.c \ 24 | pdfium/third_party/libopenjpeg20/invert.c \ 25 | pdfium/third_party/libopenjpeg20/j2k.c \ 26 | pdfium/third_party/libopenjpeg20/jp2.c \ 27 | pdfium/third_party/libopenjpeg20/mct.c \ 28 | pdfium/third_party/libopenjpeg20/mqc.c \ 29 | pdfium/third_party/libopenjpeg20/openjpeg.c \ 30 | pdfium/third_party/libopenjpeg20/opj_clock.c \ 31 | pdfium/third_party/libopenjpeg20/pi.c \ 32 | pdfium/third_party/libopenjpeg20/sparse_array.c \ 33 | pdfium/third_party/libopenjpeg20/t1.c \ 34 | pdfium/third_party/libopenjpeg20/t2.c \ 35 | pdfium/third_party/libopenjpeg20/tcd.c \ 36 | pdfium/third_party/libopenjpeg20/tgt.c \ 37 | pdfium/third_party/libopenjpeg20/thread.c \ 38 | 39 | 40 | 41 | LOCAL_C_INCLUDES := \ 42 | -I$(PWDW)/pdfium/third_party/libopenjpeg20/ \ 43 | 44 | 45 | include $(BUILD_STATIC_LIBRARY) 46 | 47 | OBJS_pdfiumopenjpeg20 := $(addsuffix .o, $(LOCAL_SRC_FILES)) 48 | OBJS_pdfiumopenjpeg20 := $(addprefix build/$(_ARCH_PX_)/pdfiumopenjpeg20/, $(OBJS_pdfiumopenjpeg20)) 49 | 50 | libpdfiumopenjpeg20.a: $(OBJS_pdfiumopenjpeg20) 51 | $(AR) -rv libpdfiumopenjpeg20.a $(OBJS_pdfiumopenjpeg20) 52 | 53 | build/$(_ARCH_PX_)/pdfiumopenjpeg20/%.o: % 54 | @echo $<; set -x;\ 55 | mkdir -p $(dir $@);\ 56 | $(CC) -c -O3 $< -o $(@) -I"../" $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) 57 | @echo "" 58 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/pdfiumzlib.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libpdfiumzlib 6 | 7 | LOCAL_ARM_MODE := arm 8 | LOCAL_NDK_STL_VARIANT := gnustl_static 9 | 10 | LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays -fexceptions 11 | LOCAL_CFLAGS += -Wno-non-virtual-dtor -Wall -fPIC 12 | 13 | # Mask some warnings. These are benign, but we probably want to fix them 14 | # upstream at some point. 15 | LOCAL_CFLAGS += -Wno-shift-negative-value -Wno-unused-parameter \ 16 | -DADLER32_SIMD_NEON -DARMV8_OS_ANDROID -DINFLATE_CHUNK_SIMD_NEON 17 | 18 | ifeq ($(arch), arm64) 19 | LOCAL_CFLAGS += -DINFLATE_CHUNK_READ_64LE 20 | endif 21 | 22 | LOCAL_SRC_FILES := \ 23 | pdfium/third_party/zlib/adler32.c \ 24 | pdfium/third_party/zlib/compress.c \ 25 | pdfium/third_party/zlib/crc32.c \ 26 | pdfium/third_party/zlib/deflate.c \ 27 | pdfium/third_party/zlib/gzclose.c \ 28 | pdfium/third_party/zlib/gzlib.c \ 29 | pdfium/third_party/zlib/gzread.c \ 30 | pdfium/third_party/zlib/gzwrite.c \ 31 | pdfium/third_party/zlib/infback.c \ 32 | pdfium/third_party/zlib/inffast.c \ 33 | pdfium/third_party/zlib/inftrees.c \ 34 | pdfium/third_party/zlib/trees.c \ 35 | pdfium/third_party/zlib/uncompr.c \ 36 | pdfium/third_party/zlib/zutil.c \ 37 | \ 38 | pdfium/third_party/zlib/adler32_simd.c \ 39 | \ 40 | pdfium/third_party/zlib/arm_features.c \ 41 | pdfium/third_party/zlib/crc32_simd.c \ 42 | \ 43 | pdfium/third_party/zlib/contrib/optimizations/inffast_chunk.c \ 44 | pdfium/third_party/zlib/contrib/optimizations/inflate.c \ 45 | \ 46 | pdfium/third_party/zlib/simd_stub.c \ 47 | 48 | 49 | 50 | ZLIB_C_INCLUDES := \ 51 | -I$(PWDW)/pdfium/third_party/zlib/ \ 52 | -I$(PWDW)/pdfium/third_party/zlib/contrib\optimizations \ 53 | -I$(NDKW)/sources/android/cpufeatures \ 54 | 55 | include $(BUILD_STATIC_LIBRARY) 56 | 57 | OBJS_pdfiumzlib := $(addsuffix .o, $(LOCAL_SRC_FILES)) 58 | OBJS_pdfiumzlib := $(addprefix build/$(_ARCH_PX_)/pdfiumzlib/, $(OBJS_pdfiumzlib)) 59 | 60 | libpdfiumzlib.a: $(OBJS_pdfiumzlib) 61 | $(AR) -rv libpdfiumzlib.a $(OBJS_pdfiumzlib) 62 | 63 | build/$(_ARCH_PX_)/pdfiumzlib/%.o: % 64 | @echo $<; set -x;\ 65 | mkdir -p $(dir $@);\ 66 | $(CC) -c -O3 $< -o $(@) -I"../" $(ZLIB_C_INCLUDES) $(LOCAL_CFLAGS) 67 | @echo "" 68 | @echo "" -------------------------------------------------------------------------------- /LibPdfium/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfium/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /LibPdfium/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /LibPdfium/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PdfiumAndroid 3 | 4 | -------------------------------------------------------------------------------- /LibPdfium/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LibPdfiumSep/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | 6 | defaultConfig { 7 | minSdkVersion 19 8 | targetSdkVersion 29 9 | versionCode 1 10 | versionName "3.2.0-beta.1" 11 | } 12 | 13 | sourceSets{ 14 | main { 15 | java.srcDirs = ['../LibPdfium/src/main/java'] 16 | jni.srcDirs = ['../LibPdfium/src/main/cpp'] 17 | jniLibs.srcDir 'src/main/libs' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | api("androidx.appcompat:appcompat:1.1.0-rc01") 24 | } -------------------------------------------------------------------------------- /LibPdfiumSep/src/androidTest/java/com/shockwave/pdfium/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.shockwave.pdfium; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | #Prebuilt libraries 4 | include $(CLEAR_VARS) 5 | LOCAL_MODULE := LibPdfium 6 | ARCH_PATH = $(TARGET_ARCH_ABI) 7 | LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libpdfium.so 8 | include $(PREBUILT_SHARED_LIBRARY) 9 | 10 | #c++_shared 11 | #include $(CLEAR_VARS) 12 | #LOCAL_MODULE := libmodc++_shared 13 | #LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libc++_shared.so 14 | #include $(PREBUILT_SHARED_LIBRARY) 15 | 16 | #Main JNI library 17 | include $(CLEAR_VARS) 18 | LOCAL_MODULE := pdfium-lib 19 | 20 | LOCAL_CFLAGS += -DHAVE_PTHREADS 21 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 22 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../LibPdfium/src/main/PDFIUM/public 23 | LOCAL_SHARED_LIBRARIES += LibPdfium 24 | LOCAL_LDLIBS += -llog -landroid -ljnigraphics 25 | 26 | LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../../LibPdfium/src/main/CPP/mainJNILib.cpp 27 | 28 | include $(BUILD_SHARED_LIBRARY) 29 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := c++_shared 2 | APP_CPPFLAGS += -fexceptions 3 | 4 | #For ANativeWindow support 5 | APP_PLATFORM = android-21 6 | 7 | APP_ABI := arm64-v8a 8 | #APP_ABI := armeabi-v7a 9 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/include/utils/Errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ERRORS_H 18 | #define ANDROID_ERRORS_H 19 | 20 | #include 21 | #include 22 | 23 | namespace android { 24 | 25 | // use this type to return error codes 26 | #ifdef HAVE_MS_C_RUNTIME 27 | typedef int status_t; 28 | #else 29 | typedef int32_t status_t; 30 | #endif 31 | 32 | /* the MS C runtime lacks a few error codes */ 33 | 34 | /* 35 | * Error codes. 36 | * All error codes are negative values. 37 | */ 38 | 39 | // Win32 #defines NO_ERROR as well. It has the same value, so there's no 40 | // real conflict, though it's a bit awkward. 41 | #ifdef _WIN32 42 | # undef NO_ERROR 43 | #endif 44 | 45 | enum { 46 | OK = 0, // Everything's swell. 47 | NO_ERROR = 0, // No errors. 48 | 49 | UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value 50 | 51 | NO_MEMORY = -ENOMEM, 52 | INVALID_OPERATION = -ENOSYS, 53 | BAD_VALUE = -EINVAL, 54 | BAD_TYPE = (UNKNOWN_ERROR + 1), 55 | NAME_NOT_FOUND = -ENOENT, 56 | PERMISSION_DENIED = -EPERM, 57 | NO_INIT = -ENODEV, 58 | ALREADY_EXISTS = -EEXIST, 59 | DEAD_OBJECT = -EPIPE, 60 | FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), 61 | JPARKS_BROKE_IT = -EPIPE, 62 | #if !defined(HAVE_MS_C_RUNTIME) 63 | BAD_INDEX = -EOVERFLOW, 64 | NOT_ENOUGH_DATA = -ENODATA, 65 | WOULD_BLOCK = -EWOULDBLOCK, 66 | TIMED_OUT = -ETIMEDOUT, 67 | UNKNOWN_TRANSACTION = -EBADMSG, 68 | #else 69 | BAD_INDEX = -E2BIG, 70 | NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), 71 | WOULD_BLOCK = (UNKNOWN_ERROR + 4), 72 | TIMED_OUT = (UNKNOWN_ERROR + 5), 73 | UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), 74 | #endif 75 | FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), 76 | }; 77 | 78 | // Restore define; enumeration is in "android" namespace, so the value defined 79 | // there won't work for Win32 code in a different namespace. 80 | #ifdef _WIN32 81 | # define NO_ERROR 0L 82 | #endif 83 | 84 | }; // namespace android 85 | 86 | // --------------------------------------------------------------------------- 87 | 88 | #endif // ANDROID_ERRORS_H 89 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/include/utils/Mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBS_UTILS_MUTEX_H 18 | #define _LIBS_UTILS_MUTEX_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(HAVE_PTHREADS) 25 | # include 26 | #endif 27 | 28 | #include 29 | 30 | // --------------------------------------------------------------------------- 31 | namespace android { 32 | // --------------------------------------------------------------------------- 33 | 34 | class Condition; 35 | 36 | /* 37 | * Simple mutex class. The implementation is system-dependent. 38 | * 39 | * The mutex must be unlocked by the thread that locked it. They are not 40 | * recursive, i.e. the same thread can't lock it multiple times. 41 | */ 42 | class Mutex { 43 | public: 44 | enum { 45 | PRIVATE = 0, 46 | SHARED = 1 47 | }; 48 | 49 | Mutex(); 50 | Mutex(const char* name); 51 | Mutex(int type, const char* name = NULL); 52 | ~Mutex(); 53 | 54 | // lock or unlock the mutex 55 | status_t lock(); 56 | void unlock(); 57 | 58 | // lock if possible; returns 0 on success, error otherwise 59 | status_t tryLock(); 60 | 61 | // Manages the mutex automatically. It'll be locked when Autolock is 62 | // constructed and released when Autolock goes out of scope. 63 | class Autolock { 64 | public: 65 | inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } 66 | inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } 67 | inline ~Autolock() { mLock.unlock(); } 68 | private: 69 | Mutex& mLock; 70 | }; 71 | 72 | private: 73 | friend class Condition; 74 | 75 | // A mutex cannot be copied 76 | Mutex(const Mutex&); 77 | Mutex& operator = (const Mutex&); 78 | 79 | #if defined(HAVE_PTHREADS) 80 | pthread_mutex_t mMutex; 81 | #else 82 | void _init(); 83 | void* mState; 84 | #endif 85 | }; 86 | 87 | // --------------------------------------------------------------------------- 88 | 89 | #if defined(HAVE_PTHREADS) 90 | 91 | inline Mutex::Mutex() { 92 | pthread_mutex_init(&mMutex, NULL); 93 | } 94 | inline Mutex::Mutex(__attribute__((unused)) const char* name) { 95 | pthread_mutex_init(&mMutex, NULL); 96 | } 97 | inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) { 98 | if (type == SHARED) { 99 | pthread_mutexattr_t attr; 100 | pthread_mutexattr_init(&attr); 101 | pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); 102 | pthread_mutex_init(&mMutex, &attr); 103 | pthread_mutexattr_destroy(&attr); 104 | } else { 105 | pthread_mutex_init(&mMutex, NULL); 106 | } 107 | } 108 | inline Mutex::~Mutex() { 109 | pthread_mutex_destroy(&mMutex); 110 | } 111 | inline status_t Mutex::lock() { 112 | return -pthread_mutex_lock(&mMutex); 113 | } 114 | inline void Mutex::unlock() { 115 | pthread_mutex_unlock(&mMutex); 116 | } 117 | inline status_t Mutex::tryLock() { 118 | return -pthread_mutex_trylock(&mMutex); 119 | } 120 | 121 | #endif // HAVE_PTHREADS 122 | 123 | // --------------------------------------------------------------------------- 124 | 125 | /* 126 | * Automatic mutex. Declare one of these at the top of a function. 127 | * When the function returns, it will go out of scope, and release the 128 | * mutex. 129 | */ 130 | 131 | typedef Mutex::Autolock AutoMutex; 132 | 133 | // --------------------------------------------------------------------------- 134 | }; // namespace android 135 | // --------------------------------------------------------------------------- 136 | 137 | #endif // _LIBS_UTILS_MUTEX_H 138 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/Readme.md: -------------------------------------------------------------------------------- 1 | Prebuilt `libpdfium.so` or `libpdfium.cr.so` go here to be linked against yielding the jni layer `libpdfium-lib.so`. 2 | 3 | ( In the AndroidStudio, Right click on this jni folder and `Open in Terminal`, then type `ndk-build`. ) 4 | -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/arm64-v8a/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/arm64-v8a/.keep_dir -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/armeabi-v7a/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/armeabi-v7a/.keep_dir -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/mips/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/mips/.keep_dir -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/mips64/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/mips64/.keep_dir -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/x86/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/x86/.keep_dir -------------------------------------------------------------------------------- /LibPdfiumSep/src/main/jni/lib/x86_64/.keep_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/LibPdfiumSep/src/main/jni/lib/x86_64/.keep_dir -------------------------------------------------------------------------------- /PDFIUM.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDFIUM.lnk -------------------------------------------------------------------------------- /PDocViewer/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | buildscript { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | } 8 | 9 | repositories { 10 | google() 11 | jcenter() 12 | } 13 | 14 | 15 | android { 16 | compileSdkVersion 29 17 | 18 | defaultConfig { 19 | applicationId "com.knziha.PDocViewer" 20 | minSdkVersion 19 21 | targetSdkVersion 29 22 | versionCode 1 23 | versionName "0.1.1" 24 | ndk { 25 | 'arm64-v8a' 26 | } 27 | //abiFilters 'x86', 'x86_64', 'armeabi-v7a', 28 | } 29 | 30 | 31 | } 32 | 33 | dependencies { 34 | api("androidx.appcompat:appcompat:1.1.0-rc01") 35 | implementation project(":LibPdfiumSep") 36 | } 37 | -------------------------------------------------------------------------------- /PDocViewer/gradle.properties: -------------------------------------------------------------------------------- 1 | ## For more details on how to configure your build environment visit 2 | # http://www.gradle.org/docs/current/userguide/build_environment.html 3 | # 4 | # Specifies the JVM arguments used for the daemon process. 5 | # The setting is particularly useful for tweaking memory settings. 6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 8 | # 9 | # When configured, Gradle will run in incubating parallel mode. 10 | # This option should only be used with decoupled projects. More details, visit 11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 | # org.gradle.parallel=true 13 | #Wed Nov 13 18:51:08 CST 2019 14 | #systemProp.http.proxyHost=127.0.0.1 15 | #systemProp.https.proxyPort=8080 16 | -------------------------------------------------------------------------------- /PDocViewer/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PDocViewer/src/main/assets/sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/assets/sample.pdf -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/CMN.java: -------------------------------------------------------------------------------- 1 | package com.knizha.PDocViewer; 2 | 3 | import android.content.res.Resources; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.PrintStream; 9 | import java.util.Arrays; 10 | import java.util.HashMap; 11 | 12 | 13 | //common 14 | public class CMN { 15 | public static long stst; 16 | public static long ststrt; 17 | public static long stst_add; 18 | public static boolean testing; 19 | 20 | public static void rt(Object... o) { 21 | ststrt = System.currentTimeMillis(); 22 | } 23 | public static void pt(Object...args) { 24 | CMN.Log(Arrays.toString(args)+" "+(System.currentTimeMillis()-ststrt)); 25 | } 26 | 27 | ///*[!0] Start debug flags and methods 28 | public static boolean testFLoatSearch; 29 | public static boolean editAll; 30 | public static boolean darkRequest=true; 31 | public static void Log(Object... o) { 32 | StringBuilder msg= new StringBuilder(); 33 | if(o!=null) 34 | for (Object o1 : o) { 35 | if(o1!=null) { 36 | if (o1 instanceof Exception) { 37 | ByteArrayOutputStream s = new ByteArrayOutputStream(); 38 | PrintStream p = new PrintStream(s); 39 | ((Exception) o1).printStackTrace(p); 40 | msg.append(s.toString()); 41 | } 42 | if (o1 instanceof Exception) { 43 | ByteArrayOutputStream s = new ByteArrayOutputStream(); 44 | PrintStream p = new PrintStream(s); 45 | ((Exception) o1).printStackTrace(p); 46 | msg.append(s.toString()); 47 | } 48 | if (o1 instanceof int[]) { 49 | msg.append(Arrays.toString((int[]) o1)); 50 | continue; 51 | } else if (o1 instanceof String[]) { 52 | msg.append(Arrays.toString((Object[]) o1)); 53 | continue; 54 | } else if (o1 instanceof short[]) { 55 | msg.append(Arrays.toString((short[]) o1)); 56 | continue; 57 | } else if (o1 instanceof byte[]) { 58 | msg.append(Arrays.toString((byte[]) o1)); 59 | continue; 60 | } 61 | } 62 | if(msg.length()>0) msg.append(", "); 63 | msg.append(o1); 64 | } 65 | if(testing) { 66 | System.out.println(msg.toString()); 67 | } else { 68 | android.util.Log.d("fatal poison",msg.toString()); 69 | } 70 | } 71 | public static void recurseLog(View v,String... depths) { 72 | String depth = depths!=null && depths.length>0?depths[0]:"- "; 73 | String depth_plus_1=depth+"- "; 74 | if(!ViewGroup.class.isInstance(v)) return; 75 | ViewGroup vg = (ViewGroup) v; 76 | for(int i=0;i 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer; 17 | 18 | import android.os.AsyncTask; 19 | 20 | import com.knizha.PDocViewer.source.DocumentSource; 21 | import com.shockwave.pdfium.PdfDocument; 22 | import com.shockwave.pdfium.PdfiumCore; 23 | import com.shockwave.pdfium.util.Size; 24 | 25 | import java.lang.ref.WeakReference; 26 | 27 | class DecodingAsyncTask extends AsyncTask { 28 | 29 | private boolean cancelled; 30 | 31 | private WeakReference pdfViewReference; 32 | 33 | private PdfiumCore pdfiumCore; 34 | private String password; 35 | private DocumentSource docSource; 36 | private PdfFile pdfFile; 37 | 38 | DecodingAsyncTask(DocumentSource docSource, String password, PDocView pDocView, PdfiumCore pdfiumCore) { 39 | this.docSource = docSource; 40 | this.cancelled = false; 41 | this.pdfViewReference = new WeakReference<>(pDocView); 42 | this.password = password; 43 | this.pdfiumCore = pdfiumCore; 44 | } 45 | 46 | @Override 47 | protected Throwable doInBackground(Void... params) { 48 | try { 49 | PDocView pDocView = pdfViewReference.get(); 50 | if (pDocView != null) { 51 | PdfDocument pdfDocument = docSource.createDocument(pDocView.getContext(), pdfiumCore, password); 52 | pdfFile = new PdfFile(pdfiumCore, pdfDocument, pDocView.getPageFitPolicy(), getViewSize(pDocView), 53 | pDocView.isSwipeVertical(), pDocView.getSpacingPx(), pDocView.isAutoSpacingEnabled(), 54 | pDocView.isFitEachPage()); 55 | return null; 56 | } else { 57 | return new NullPointerException("pdfView == null"); 58 | } 59 | 60 | } catch (Throwable t) { 61 | return t; 62 | } 63 | } 64 | 65 | private Size getViewSize(PDocView pDocView) { 66 | return new Size(pDocView.getWidth(), pDocView.getHeight()); 67 | } 68 | 69 | @Override 70 | protected void onPostExecute(Throwable t) { 71 | PDocView pDocView = pdfViewReference.get(); 72 | if (pDocView != null) { 73 | if (t != null) { 74 | pDocView.loadError(t); 75 | return; 76 | } 77 | if (!cancelled) { 78 | pDocView.loadComplete(pdfFile); 79 | } 80 | } 81 | } 82 | 83 | @Override 84 | protected void onCancelled() { 85 | cancelled = true; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/PDocBenchMarkctivity.java: -------------------------------------------------------------------------------- 1 | package com.knizha.PDocViewer; 2 | 3 | import android.graphics.Bitmap; 4 | import android.os.Bundle; 5 | import android.widget.Toast; 6 | 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | import java.io.IOException; 10 | 11 | public class PDocBenchMarkctivity extends AppCompatActivity { 12 | 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | //ImageviewDebugBinding UIData = DataBindingUtil.setContentView(this, R.layout.imageview_debug); 18 | 19 | 20 | try { 21 | //PDocument pdoc = new PDocument(this, "/sdcard/myFolder/sample_hetero_dimension.pdf"); 22 | PDocument pdoc = new PDocument(this, "/sdcard/myFolder/Gpu Pro 1.pdf"); 23 | 24 | 25 | CMN.rt(); 26 | Bitmap bm = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888); 27 | for (int i = 0; i < 10; i++) { 28 | bm = pdoc.drawTumbnail(bm, i, 1); 29 | } 30 | long time = System.currentTimeMillis() - CMN.ststrt; 31 | 32 | Toast.makeText(this, "PDF_RENDER TIME::" + time, Toast.LENGTH_LONG).show(); 33 | CMN.Log("PDF_RENDER TIME::", time); 34 | 35 | 36 | } catch (IOException e) { 37 | e.printStackTrace(); 38 | } 39 | 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/PDocument.java: -------------------------------------------------------------------------------- 1 | package com.knizha.PDocViewer; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.os.ParcelFileDescriptor; 6 | import android.util.SparseArray; 7 | 8 | import com.shockwave.pdfium.PdfDocument; 9 | import com.shockwave.pdfium.PdfiumCore; 10 | import com.shockwave.pdfium.util.Size; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.HashMap; 15 | import java.util.concurrent.atomic.AtomicLong; 16 | 17 | public class PDocument { 18 | public final String path; 19 | public /*final*/ PDocPage[] mPDocPages; 20 | public static PdfiumCore pdfiumCore; 21 | public PdfDocument pdfDocument; 22 | public int maxPageWidth; 23 | public int maxPageHeight; 24 | public long height; 25 | public int _num_entries; 26 | private int _anchor_page; 27 | private HashMap bTMP = new HashMap<>(); 28 | 29 | class PDocPage { 30 | final int pageIdx; 31 | final Size size; 32 | public int startY = 0; 33 | public int startX = 0; 34 | public int maxX; 35 | public int maxY; 36 | long OffsetAlongScrollAxis; 37 | final AtomicLong pid=new AtomicLong(); 38 | PDocPage(int pageIdx, Size size) { 39 | this.pageIdx = pageIdx; 40 | this.size = size; 41 | } 42 | 43 | public void open() { 44 | if(pid.get()==0) { 45 | synchronized(pid) { 46 | if(pid.get()==0) { 47 | pid.set(pdfiumCore.openPage(pdfDocument, pageIdx)); 48 | } 49 | } 50 | } 51 | } 52 | 53 | 54 | @Override 55 | public String toString() { 56 | return "PDocPage{" + 57 | "pageIdx=" + pageIdx + 58 | '}'; 59 | } 60 | 61 | public int getHorizontalOffset() { 62 | if(size.getWidth()!=maxPageWidth) { 63 | return (maxPageWidth-size.getWidth())/2; 64 | } 65 | return 0; 66 | } 67 | } 68 | 69 | public PDocument(Context c, String path) throws IOException { 70 | this.path = path; 71 | if(pdfiumCore==null) { 72 | pdfiumCore = new PdfiumCore(c); 73 | } 74 | File f = new File(path); 75 | ParcelFileDescriptor pfd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY); 76 | pdfDocument = pdfiumCore.newDocument(pfd); 77 | _num_entries = pdfiumCore.getPageCount(pdfDocument); 78 | mPDocPages = new PDocPage[_num_entries]; 79 | height=0; 80 | for (int i = 0; i < _num_entries; i++) { 81 | Size size = pdfiumCore.getPageSize(pdfDocument, i); 82 | PDocPage page = new PDocPage(i, size); 83 | mPDocPages[i]=page; 84 | page.OffsetAlongScrollAxis=height; 85 | height+=size.getHeight()+60; 86 | //if(i<10) CMN.Log("mPDocPages", i, size.getWidth(), size.getHeight()); 87 | maxPageWidth = Math.max(maxPageWidth, size.getWidth()); 88 | maxPageHeight = Math.max(maxPageHeight, size.getHeight()); 89 | } 90 | if(_num_entries>0) { 91 | PDocPage page = mPDocPages[_num_entries-1]; 92 | height = page.OffsetAlongScrollAxis+page.size.getHeight(); 93 | } 94 | } 95 | 96 | public Bitmap renderBitmap(PDocPage page, Bitmap bitmap, float scale) { 97 | Size size = page.size; 98 | int w = (int) (size.getWidth()*scale); 99 | int h = (int) (size.getHeight()*scale); 100 | //CMN.Log("renderBitmap", w, h, bitmap.getWidth(), bitmap.getHeight()); 101 | page.open(); 102 | pdfiumCore.renderPageBitmap(pdfDocument, bitmap, page.pageIdx, 0, 0, w, h ,false); 103 | return bitmap; 104 | } 105 | 106 | public Bitmap renderRegionBitmap(PDocPage page, Bitmap bitmap, int startX, int startY, int srcW, int srcH) { 107 | int w = bitmap.getWidth(); 108 | int h = bitmap.getHeight(); 109 | page.open(); 110 | //CMN.Log("renderRegion", w, h, startX, startY, srcW, srcH); 111 | pdfiumCore.renderPageBitmap(pdfDocument, bitmap, page.pageIdx, startX, startY, srcW, srcH ,false); 112 | return bitmap; 113 | } 114 | 115 | public Bitmap drawTumbnail(Bitmap bitmap, int pageIdx, float scale) { 116 | PDocPage page = mPDocPages[pageIdx]; 117 | Size size = page.size; 118 | int w = (int) (size.getWidth()*scale); 119 | int h = (int) (size.getHeight()*scale); 120 | page.open(); 121 | Bitmap OneSmallStep = bitmap; 122 | boolean recreate=OneSmallStep.isRecycled(); 123 | if(!recreate && (w!=OneSmallStep.getWidth()||h!=OneSmallStep.getHeight())) { 124 | if(OneSmallStep.getAllocationByteCount()>=w*h*4) { 125 | OneSmallStep.reconfigure(w, h, Bitmap.Config.ARGB_8888); 126 | } else recreate=true; 127 | } 128 | if(recreate) { 129 | OneSmallStep.recycle(); 130 | OneSmallStep = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); 131 | } 132 | renderBitmap(page, OneSmallStep, scale); 133 | //pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageIdx, 0, 0, w, h ,false); 134 | return bitmap; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/RenderingHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer; 17 | 18 | import android.graphics.Bitmap; 19 | import android.graphics.Matrix; 20 | import android.graphics.Rect; 21 | import android.graphics.RectF; 22 | import android.os.Handler; 23 | import android.os.Looper; 24 | import android.os.Message; 25 | import android.util.Log; 26 | 27 | import com.knizha.PDocViewer.exception.PageRenderingException; 28 | import com.knizha.PDocViewer.model.PagePart; 29 | 30 | /** 31 | * A {@link Handler} that will process incoming {@link RenderingTask} messages 32 | * and alert {@link PDocView#onBitmapRendered(PagePart)} when the portion of the 33 | * PDF is ready to render. 34 | */ 35 | class RenderingHandler extends Handler { 36 | /** 37 | * {@link Message#what} kind of message this handler processes. 38 | */ 39 | static final int MSG_RENDER_TASK = 1; 40 | 41 | private static final String TAG = RenderingHandler.class.getName(); 42 | 43 | private PDocView pDocView; 44 | 45 | private RectF renderBounds = new RectF(); 46 | private Rect roundedRenderBounds = new Rect(); 47 | private Matrix renderMatrix = new Matrix(); 48 | private boolean running = false; 49 | 50 | RenderingHandler(Looper looper, PDocView pDocView) { 51 | super(looper); 52 | this.pDocView = pDocView; 53 | } 54 | 55 | void addRenderingTask(int page, float width, float height, RectF bounds, boolean thumbnail, int cacheOrder, boolean bestQuality, boolean annotationRendering) { 56 | RenderingTask task = new RenderingTask(width, height, bounds, page, thumbnail, cacheOrder, bestQuality, annotationRendering); 57 | Message msg = obtainMessage(MSG_RENDER_TASK, task); 58 | sendMessage(msg); 59 | } 60 | 61 | //仅仅一个task哎 62 | @Override 63 | public void handleMessage(Message message) { 64 | RenderingTask task = (RenderingTask) message.obj; 65 | try { 66 | final PagePart part = proceed(task); 67 | if (part != null) { 68 | if (running) { 69 | pDocView.post(new Runnable() { 70 | @Override 71 | public void run() { 72 | pDocView.onBitmapRendered(part); 73 | } 74 | }); 75 | } else { 76 | part.getRenderedBitmap().recycle(); 77 | } 78 | } 79 | } catch (final PageRenderingException ex) { 80 | pDocView.post(new Runnable() { 81 | @Override 82 | public void run() { 83 | pDocView.onPageError(ex); 84 | } 85 | }); 86 | } 87 | } 88 | 89 | private PagePart proceed(RenderingTask threadedTask) throws PageRenderingException { 90 | PdfFile processing_docfile = pDocView.pdfFile; 91 | processing_docfile.openPage(threadedTask.page); 92 | int w = Math.round(threadedTask.width); 93 | int h = Math.round(threadedTask.height); 94 | if (w == 0 || h == 0 || processing_docfile.pageHasError(threadedTask.page)) { 95 | return null; 96 | } 97 | Bitmap render; 98 | try { 99 | render = Bitmap.createBitmap(w, h, threadedTask.bestQuality ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); 100 | } catch (IllegalArgumentException e) { 101 | Log.e(TAG, "Cannot create bitmap", e); 102 | return null; 103 | } 104 | calculateBounds(w, h, threadedTask.bounds); 105 | 106 | processing_docfile.renderPageBitmap(render, threadedTask.page, roundedRenderBounds, threadedTask.annotationRendering); 107 | 108 | return new PagePart(threadedTask.page, render, 109 | threadedTask.bounds, threadedTask.thumbnail, 110 | threadedTask.cacheOrder); 111 | } 112 | 113 | private void calculateBounds(int width, int height, RectF pageSliceBounds) { 114 | renderMatrix.reset(); 115 | renderMatrix.postTranslate(-pageSliceBounds.left * width, -pageSliceBounds.top * height); 116 | renderMatrix.postScale(1 / pageSliceBounds.width(), 1 / pageSliceBounds.height()); 117 | 118 | renderBounds.set(0, 0, width, height); 119 | renderMatrix.mapRect(renderBounds); 120 | renderBounds.round(roundedRenderBounds); 121 | } 122 | 123 | void stop() { 124 | running = false; 125 | } 126 | 127 | void start() { 128 | running = true; 129 | } 130 | 131 | private class RenderingTask { 132 | float width, height; 133 | RectF bounds; 134 | int page; 135 | boolean thumbnail; 136 | int cacheOrder; 137 | boolean bestQuality; 138 | boolean annotationRendering; 139 | RenderingTask(float width, float height, RectF bounds, int page, boolean thumbnail, int cacheOrder, boolean bestQuality, boolean annotationRendering) { 140 | this.page = page; 141 | this.width = width; 142 | this.height = height; 143 | this.bounds = bounds; 144 | this.thumbnail = thumbnail; 145 | this.cacheOrder = cacheOrder; 146 | this.bestQuality = bestQuality; 147 | this.annotationRendering = annotationRendering; 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/exception/FileNotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.exception; 17 | 18 | @Deprecated 19 | public class FileNotFoundException extends RuntimeException { 20 | 21 | public FileNotFoundException(String detailMessage) { 22 | super(detailMessage); 23 | } 24 | 25 | public FileNotFoundException(String detailMessage, Throwable throwable) { 26 | super(detailMessage, throwable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/exception/PageRenderingException.java: -------------------------------------------------------------------------------- 1 | package com.knizha.PDocViewer.exception; 2 | 3 | public class PageRenderingException extends Exception { 4 | private final int page; 5 | 6 | public PageRenderingException(int page, Throwable cause) { 7 | super(cause); 8 | this.page = page; 9 | } 10 | 11 | public int getPage() { 12 | return page; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/link/DefaultLinkHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.link; 17 | 18 | import android.content.Context; 19 | import android.content.Intent; 20 | import android.net.Uri; 21 | import android.util.Log; 22 | 23 | import com.knizha.PDocViewer.PDocView; 24 | import com.knizha.PDocViewer.model.LinkTapEvent; 25 | 26 | public class DefaultLinkHandler implements LinkHandler { 27 | 28 | private static final String TAG = DefaultLinkHandler.class.getSimpleName(); 29 | 30 | private PDocView pDocView; 31 | 32 | public DefaultLinkHandler(PDocView pDocView) { 33 | this.pDocView = pDocView; 34 | } 35 | 36 | @Override 37 | public void handleLinkEvent(LinkTapEvent event) { 38 | String uri = event.getLink().getUri(); 39 | Integer page = event.getLink().getDestPageIdx(); 40 | if (uri != null && !uri.isEmpty()) { 41 | handleUri(uri); 42 | } else if (page != null) { 43 | handlePage(page); 44 | } 45 | } 46 | 47 | private void handleUri(String uri) { 48 | Uri parsedUri = Uri.parse(uri); 49 | Intent intent = new Intent(Intent.ACTION_VIEW, parsedUri); 50 | Context context = pDocView.getContext(); 51 | if (intent.resolveActivity(context.getPackageManager()) != null) { 52 | context.startActivity(intent); 53 | } else { 54 | Log.w(TAG, "No activity found for URI: " + uri); 55 | } 56 | } 57 | 58 | private void handlePage(int page) { 59 | pDocView.jumpTo(page); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/link/LinkHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.link; 17 | 18 | import com.knizha.PDocViewer.model.LinkTapEvent; 19 | 20 | public interface LinkHandler { 21 | 22 | /** 23 | * Called when link was tapped by user 24 | * 25 | * @param event current event 26 | */ 27 | void handleLinkEvent(LinkTapEvent event); 28 | } 29 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/Callbacks.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | import android.view.MotionEvent; 19 | 20 | import com.knizha.PDocViewer.link.LinkHandler; 21 | import com.knizha.PDocViewer.model.LinkTapEvent; 22 | 23 | public class Callbacks { 24 | 25 | /** 26 | * Call back object to call when the PDF is loaded 27 | */ 28 | private OnLoadCompleteListener onLoadCompleteListener; 29 | 30 | /** 31 | * Call back object to call when document loading error occurs 32 | */ 33 | private OnErrorListener onErrorListener; 34 | 35 | /** 36 | * Call back object to call when the page load error occurs 37 | */ 38 | private OnPageErrorListener onPageErrorListener; 39 | 40 | /** 41 | * Call back object to call when the document is initially rendered 42 | */ 43 | private OnRenderListener onRenderListener; 44 | 45 | /** 46 | * Call back object to call when the page has changed 47 | */ 48 | private OnPageChangeListener onPageChangeListener; 49 | 50 | /** 51 | * Call back object to call when the page is scrolled 52 | */ 53 | private OnPageScrollListener onPageScrollListener; 54 | 55 | /** 56 | * Call back object to call when the above layer is to drawn 57 | */ 58 | private OnDrawListener onDrawListener; 59 | 60 | private OnDrawListener onDrawAllListener; 61 | 62 | /** 63 | * Call back object to call when the user does a tap gesture 64 | */ 65 | private OnTapListener onTapListener; 66 | 67 | /** 68 | * Call back object to call when the user does a long tap gesture 69 | */ 70 | private OnLongPressListener onLongPressListener; 71 | 72 | /** 73 | * Call back object to call when clicking link 74 | */ 75 | private LinkHandler linkHandler; 76 | 77 | public void setOnLoadComplete(OnLoadCompleteListener onLoadCompleteListener) { 78 | this.onLoadCompleteListener = onLoadCompleteListener; 79 | } 80 | 81 | public void callOnLoadComplete(int pagesCount) { 82 | if (onLoadCompleteListener != null) { 83 | onLoadCompleteListener.loadComplete(pagesCount); 84 | } 85 | } 86 | 87 | public void setOnError(OnErrorListener onErrorListener) { 88 | this.onErrorListener = onErrorListener; 89 | } 90 | 91 | public OnErrorListener getOnError() { 92 | return onErrorListener; 93 | } 94 | 95 | public void setOnPageError(OnPageErrorListener onPageErrorListener) { 96 | this.onPageErrorListener = onPageErrorListener; 97 | } 98 | 99 | public boolean callOnPageError(int page, Throwable error) { 100 | if (onPageErrorListener != null) { 101 | onPageErrorListener.onPageError(page, error); 102 | return true; 103 | } 104 | return false; 105 | } 106 | 107 | public void setOnRender(OnRenderListener onRenderListener) { 108 | this.onRenderListener = onRenderListener; 109 | } 110 | 111 | public void callOnRender(int pagesCount) { 112 | if (onRenderListener != null) { 113 | onRenderListener.onInitiallyRendered(pagesCount); 114 | } 115 | } 116 | 117 | public void setOnPageChange(OnPageChangeListener onPageChangeListener) { 118 | this.onPageChangeListener = onPageChangeListener; 119 | } 120 | 121 | public void callOnPageChange(int page, int pagesCount) { 122 | if (onPageChangeListener != null) { 123 | onPageChangeListener.onPageChanged(page, pagesCount); 124 | } 125 | } 126 | 127 | public void setOnPageScroll(OnPageScrollListener onPageScrollListener) { 128 | this.onPageScrollListener = onPageScrollListener; 129 | } 130 | 131 | public void callOnPageScroll(int currentPage, float offset) { 132 | if (onPageScrollListener != null) { 133 | onPageScrollListener.onPageScrolled(currentPage, offset); 134 | } 135 | } 136 | 137 | public void setOnDraw(OnDrawListener onDrawListener) { 138 | this.onDrawListener = onDrawListener; 139 | } 140 | 141 | public OnDrawListener getOnDraw() { 142 | return onDrawListener; 143 | } 144 | 145 | public void setOnDrawAll(OnDrawListener onDrawAllListener) { 146 | this.onDrawAllListener = onDrawAllListener; 147 | } 148 | 149 | public OnDrawListener getOnDrawAll() { 150 | return onDrawAllListener; 151 | } 152 | 153 | public void setOnTap(OnTapListener onTapListener) { 154 | this.onTapListener = onTapListener; 155 | } 156 | 157 | public boolean callOnTap(MotionEvent event) { 158 | return onTapListener != null && onTapListener.onTap(event); 159 | } 160 | 161 | public void setOnLongPress(OnLongPressListener onLongPressListener) { 162 | this.onLongPressListener = onLongPressListener; 163 | } 164 | 165 | public void callOnLongPress(MotionEvent event) { 166 | if (onLongPressListener != null) { 167 | onLongPressListener.onLongPress(event); 168 | } 169 | } 170 | 171 | public void setLinkHandler(LinkHandler linkHandler) { 172 | this.linkHandler = linkHandler; 173 | } 174 | 175 | public void callLinkHandler(LinkTapEvent event) { 176 | if (linkHandler != null) { 177 | linkHandler.handleLinkEvent(event); 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnDrawListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | import android.graphics.Canvas; 19 | 20 | /** 21 | * This interface allows an extern class to draw 22 | * something on the PDFView canvas, above all images. 23 | */ 24 | public interface OnDrawListener { 25 | 26 | /** 27 | * This method is called when the PDFView is 28 | * drawing its view. 29 | *

30 | * The page is starting at (0,0) 31 | * 32 | * @param canvas The canvas on which to draw things. 33 | * @param pageWidth The width of the current page. 34 | * @param pageHeight The height of the current page. 35 | * @param displayedPage The current page index 36 | */ 37 | void onLayerDrawn(Canvas canvas, float pageWidth, float pageHeight, int displayedPage); 38 | } 39 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnErrorListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | public interface OnErrorListener { 19 | 20 | /** 21 | * Called if error occurred while opening PDF 22 | * @param t Throwable with error 23 | */ 24 | void onError(Throwable t); 25 | } 26 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnLoadCompleteListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | /** 19 | * Implement this interface to receive events from PDFView 20 | * when loading is complete. 21 | */ 22 | public interface OnLoadCompleteListener { 23 | 24 | /** 25 | * Called when the PDF is loaded 26 | * @param nbPages the number of pages in this PDF file 27 | */ 28 | void loadComplete(int nbPages); 29 | } 30 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnLongPressListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | import android.view.MotionEvent; 19 | 20 | /** 21 | * Implement this interface to receive events from PDFView 22 | * when view has been long pressed 23 | */ 24 | public interface OnLongPressListener { 25 | 26 | /** 27 | * Called when the user has a long tap gesture, before processing scroll handle toggling 28 | * 29 | * @param e MotionEvent that registered as a confirmed long press 30 | */ 31 | void onLongPress(MotionEvent e); 32 | } 33 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnPageChangeListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | /** 19 | * Implements this interface to receive events from PDFView 20 | * when a page has changed through swipe 21 | */ 22 | public interface OnPageChangeListener { 23 | 24 | /** 25 | * Called when the user use swipe to change page 26 | * 27 | * @param page the new page displayed, starting from 0 28 | * @param pageCount the total page count 29 | */ 30 | void onPageChanged(int page, int pageCount); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnPageErrorListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | public interface OnPageErrorListener { 19 | 20 | /** 21 | * Called if error occurred while loading PDF page 22 | * @param t Throwable with error 23 | */ 24 | void onPageError(int page, Throwable t); 25 | } 26 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnPageScrollListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | import com.knizha.PDocViewer.PDocView; 19 | 20 | /** 21 | * Implements this interface to receive events from PDFView 22 | * when a page has been scrolled 23 | */ 24 | public interface OnPageScrollListener { 25 | 26 | /** 27 | * Called on every move while scrolling 28 | * 29 | * @param page current page index 30 | * @param positionOffset see {@link PDocView#getPositionOffset()} 31 | */ 32 | void onPageScrolled(int page, float positionOffset); 33 | } 34 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnRenderListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | public interface OnRenderListener { 19 | 20 | /** 21 | * Called only once, when document is rendered 22 | * @param nbPages number of pages 23 | */ 24 | void onInitiallyRendered(int nbPages); 25 | } 26 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/listener/OnTapListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.listener; 17 | 18 | import android.view.MotionEvent; 19 | 20 | /** 21 | * Implement this interface to receive events from PDFView 22 | * when view has been touched 23 | */ 24 | public interface OnTapListener { 25 | 26 | /** 27 | * Called when the user has a tap gesture, before processing scroll handle toggling 28 | * 29 | * @param e MotionEvent that registered as a confirmed single tap 30 | * @return true if the single tap was handled, false to toggle scroll handle 31 | */ 32 | boolean onTap(MotionEvent e); 33 | } 34 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/model/LinkTapEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.model; 17 | 18 | import android.graphics.RectF; 19 | 20 | import com.shockwave.pdfium.PdfDocument; 21 | 22 | public class LinkTapEvent { 23 | private float originalX; 24 | private float originalY; 25 | private float documentX; 26 | private float documentY; 27 | private RectF mappedLinkRect; 28 | private PdfDocument.Link link; 29 | 30 | public LinkTapEvent(float originalX, float originalY, float documentX, float documentY, RectF mappedLinkRect, PdfDocument.Link link) { 31 | this.originalX = originalX; 32 | this.originalY = originalY; 33 | this.documentX = documentX; 34 | this.documentY = documentY; 35 | this.mappedLinkRect = mappedLinkRect; 36 | this.link = link; 37 | } 38 | 39 | public float getOriginalX() { 40 | return originalX; 41 | } 42 | 43 | public float getOriginalY() { 44 | return originalY; 45 | } 46 | 47 | public float getDocumentX() { 48 | return documentX; 49 | } 50 | 51 | public float getDocumentY() { 52 | return documentY; 53 | } 54 | 55 | public RectF getMappedLinkRect() { 56 | return mappedLinkRect; 57 | } 58 | 59 | public PdfDocument.Link getLink() { 60 | return link; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/model/PagePart.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.model; 17 | 18 | import android.graphics.Bitmap; 19 | import android.graphics.RectF; 20 | 21 | public class PagePart { 22 | 23 | private int page; 24 | 25 | private Bitmap renderedBitmap; 26 | 27 | private RectF pageRelativeBounds; 28 | 29 | private boolean thumbnail; 30 | 31 | private int cacheOrder; 32 | 33 | public PagePart(int page, Bitmap renderedBitmap, RectF pageRelativeBounds, boolean thumbnail, int cacheOrder) { 34 | super(); 35 | this.page = page; 36 | this.renderedBitmap = renderedBitmap; 37 | this.pageRelativeBounds = pageRelativeBounds; 38 | this.thumbnail = thumbnail; 39 | this.cacheOrder = cacheOrder; 40 | } 41 | 42 | public int getCacheOrder() { 43 | return cacheOrder; 44 | } 45 | 46 | public int getPage() { 47 | return page; 48 | } 49 | 50 | public Bitmap getRenderedBitmap() { 51 | return renderedBitmap; 52 | } 53 | 54 | public RectF getPageRelativeBounds() { 55 | return pageRelativeBounds; 56 | } 57 | 58 | public boolean isThumbnail() { 59 | return thumbnail; 60 | } 61 | 62 | public void setCacheOrder(int cacheOrder) { 63 | this.cacheOrder = cacheOrder; 64 | } 65 | 66 | @Override 67 | public boolean equals(Object obj) { 68 | if (!(obj instanceof PagePart)) { 69 | return false; 70 | } 71 | 72 | PagePart part = (PagePart) obj; 73 | return part.getPage() == page 74 | && part.getPageRelativeBounds().left == pageRelativeBounds.left 75 | && part.getPageRelativeBounds().right == pageRelativeBounds.right 76 | && part.getPageRelativeBounds().top == pageRelativeBounds.top 77 | && part.getPageRelativeBounds().bottom == pageRelativeBounds.bottom; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/scroll/ScrollHandle.java: -------------------------------------------------------------------------------- 1 | package com.knizha.PDocViewer.scroll; 2 | 3 | import com.knizha.PDocViewer.PDocView; 4 | 5 | public interface ScrollHandle { 6 | 7 | /** 8 | * Used to move the handle, called internally by PDFView 9 | * 10 | * @param position current scroll ratio between 0 and 1 11 | */ 12 | void setScroll(float position); 13 | 14 | /** 15 | * Method called by PDFView after setting scroll handle. 16 | * Do not call this method manually. 17 | * For usage sample see {@link DefaultScrollHandle} 18 | * 19 | * @param pDocView PDFView instance 20 | */ 21 | void setupLayout(PDocView pDocView); 22 | 23 | /** 24 | * Method called by PDFView when handle should be removed from layout 25 | * Do not call this method manually. 26 | */ 27 | void destroyLayout(); 28 | 29 | /** 30 | * Set page number displayed on handle 31 | * 32 | * @param pageNum page number 33 | */ 34 | void setPageNum(int pageNum); 35 | 36 | /** 37 | * Get handle visibility 38 | * 39 | * @return true if handle is visible, false otherwise 40 | */ 41 | boolean shown(); 42 | 43 | /** 44 | * Show handle 45 | */ 46 | void show(); 47 | 48 | /** 49 | * Hide handle immediately 50 | */ 51 | void hide(); 52 | 53 | /** 54 | * Hide handle after some time (defined by implementation) 55 | */ 56 | void hideDelayed(); 57 | } 58 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/AssetSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | 19 | import android.content.Context; 20 | import android.os.ParcelFileDescriptor; 21 | 22 | import com.knizha.PDocViewer.util.FileUtils; 23 | import com.shockwave.pdfium.PdfDocument; 24 | import com.shockwave.pdfium.PdfiumCore; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | 29 | public class AssetSource implements DocumentSource { 30 | 31 | private final String assetName; 32 | 33 | public AssetSource(String assetName) { 34 | this.assetName = assetName; 35 | } 36 | 37 | @Override 38 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException { 39 | File f = FileUtils.fileFromAsset(context, assetName); 40 | ParcelFileDescriptor pfd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY); 41 | return core.newDocument(pfd, password); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/ByteArraySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | import android.content.Context; 19 | 20 | import com.shockwave.pdfium.PdfDocument; 21 | import com.shockwave.pdfium.PdfiumCore; 22 | 23 | import java.io.IOException; 24 | 25 | public class ByteArraySource implements DocumentSource { 26 | 27 | private byte[] data; 28 | 29 | public ByteArraySource(byte[] data) { 30 | this.data = data; 31 | } 32 | 33 | @Override 34 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException { 35 | return core.newDocument(data, password); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/DocumentSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | import android.content.Context; 19 | 20 | import com.shockwave.pdfium.PdfDocument; 21 | import com.shockwave.pdfium.PdfiumCore; 22 | 23 | import java.io.IOException; 24 | 25 | public interface DocumentSource { 26 | PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException; 27 | } 28 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/FileSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | import android.content.Context; 19 | import android.os.ParcelFileDescriptor; 20 | 21 | import com.shockwave.pdfium.PdfDocument; 22 | import com.shockwave.pdfium.PdfiumCore; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | 27 | public class FileSource implements DocumentSource { 28 | 29 | private File file; 30 | 31 | public FileSource(File file) { 32 | this.file = file; 33 | } 34 | 35 | @Override 36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException { 37 | ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); 38 | return core.newDocument(pfd, password); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/InputStreamSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | import android.content.Context; 19 | 20 | import com.knizha.PDocViewer.util.Util; 21 | import com.shockwave.pdfium.PdfDocument; 22 | import com.shockwave.pdfium.PdfiumCore; 23 | 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | 27 | public class InputStreamSource implements DocumentSource { 28 | 29 | private InputStream inputStream; 30 | 31 | public InputStreamSource(InputStream inputStream) { 32 | this.inputStream = inputStream; 33 | } 34 | 35 | @Override 36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException { 37 | return core.newDocument(Util.toByteArray(inputStream), password); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/source/UriSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.source; 17 | 18 | import android.content.Context; 19 | import android.net.Uri; 20 | import android.os.ParcelFileDescriptor; 21 | 22 | import com.shockwave.pdfium.PdfDocument; 23 | import com.shockwave.pdfium.PdfiumCore; 24 | 25 | import java.io.IOException; 26 | 27 | public class UriSource implements DocumentSource { 28 | 29 | private Uri uri; 30 | 31 | public UriSource(Uri uri) { 32 | this.uri = uri; 33 | } 34 | 35 | @Override 36 | public PdfDocument createDocument(Context context, PdfiumCore core, String password) throws IOException { 37 | ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r"); 38 | return core.newDocument(pfd, password); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class ArrayUtils { 22 | 23 | private ArrayUtils() { 24 | // Prevents instantiation 25 | } 26 | 27 | /** Transforms (0,1,2,2,3) to (0,1,2,3) */ 28 | public static int[] deleteDuplicatedPages(int[] pages) { 29 | List result = new ArrayList<>(); 30 | int lastInt = -1; 31 | for (Integer currentInt : pages) { 32 | if (lastInt != currentInt) { 33 | result.add(currentInt); 34 | } 35 | lastInt = currentInt; 36 | } 37 | int[] arrayResult = new int[result.size()]; 38 | for (int i = 0; i < result.size(); i++) { 39 | arrayResult[i] = result.get(i); 40 | } 41 | return arrayResult; 42 | } 43 | 44 | /** Transforms (0, 4, 4, 6, 6, 6, 3) into (0, 1, 1, 2, 2, 2, 3) */ 45 | public static int[] calculateIndexesInDuplicateArray(int[] originalUserPages) { 46 | int[] result = new int[originalUserPages.length]; 47 | if (originalUserPages.length == 0) { 48 | return result; 49 | } 50 | 51 | int index = 0; 52 | result[0] = index; 53 | for (int i = 1; i < originalUserPages.length; i++) { 54 | if (originalUserPages[i] != originalUserPages[i - 1]) { 55 | index++; 56 | } 57 | result[i] = index; 58 | } 59 | 60 | return result; 61 | } 62 | 63 | public static String arrayToString(int[] array) { 64 | StringBuilder builder = new StringBuilder("["); 65 | for (int i = 0; i < array.length; i++) { 66 | builder.append(array[i]); 67 | if (i != array.length - 1) { 68 | builder.append(","); 69 | } 70 | } 71 | builder.append("]"); 72 | return builder.toString(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/Constants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | public class Constants { 19 | 20 | public static boolean DEBUG_MODE = false; 21 | 22 | /** Between 0 and 1, the thumbnails quality (default 0.3). Increasing this value may cause performance decrease */ 23 | public static float THUMBNAIL_RATIO = 0.3f; 24 | 25 | /** 26 | * The size of the rendered parts (default 256) 27 | * Tinier : a little bit slower to have the whole page rendered but more reactive. 28 | * Bigger : user will have to wait longer to have the first visual results 29 | */ 30 | public static float PART_SIZE = 256; 31 | 32 | /** Part of document above and below screen that should be preloaded, in dp */ 33 | public static int PRELOAD_OFFSET = 20; 34 | 35 | public static class Cache { 36 | 37 | /** The size of the cache (number of bitmaps kept) */ 38 | public static int CACHE_SIZE = 120; 39 | 40 | public static int THUMBNAILS_CACHE_SIZE = 8; 41 | } 42 | 43 | public static class Pinch { 44 | 45 | public static float MAXIMUM_ZOOM = 10; 46 | 47 | public static float MINIMUM_ZOOM = 1; 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | import android.content.Context; 19 | 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.io.OutputStream; 25 | 26 | public class FileUtils { 27 | 28 | private FileUtils() { 29 | // Prevents instantiation 30 | } 31 | 32 | public static File fileFromAsset(Context context, String assetName) throws IOException { 33 | File outFile = new File(context.getCacheDir(), assetName + "-pdfview.pdf"); 34 | if (assetName.contains("/")) { 35 | outFile.getParentFile().mkdirs(); 36 | } 37 | copy(context.getAssets().open(assetName), outFile); 38 | return outFile; 39 | } 40 | 41 | public static void copy(InputStream inputStream, File output) throws IOException { 42 | OutputStream outputStream = null; 43 | try { 44 | outputStream = new FileOutputStream(output); 45 | int read = 0; 46 | byte[] bytes = new byte[1024]; 47 | while ((read = inputStream.read(bytes)) != -1) { 48 | outputStream.write(bytes, 0, read); 49 | } 50 | } finally { 51 | try { 52 | if (inputStream != null) { 53 | inputStream.close(); 54 | } 55 | } finally { 56 | if (outputStream != null) { 57 | outputStream.close(); 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/FitPolicy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | public enum FitPolicy { 19 | WIDTH, HEIGHT, BOTH 20 | } 21 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/MathUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | public class MathUtils { 19 | 20 | static private final int BIG_ENOUGH_INT = 16 * 1024; 21 | static private final double BIG_ENOUGH_FLOOR = BIG_ENOUGH_INT; 22 | static private final double BIG_ENOUGH_CEIL = 16384.999999999996; 23 | 24 | private MathUtils() { 25 | // Prevents instantiation 26 | } 27 | 28 | /** 29 | * Limits the given number between the other values 30 | * @param number The number to limit. 31 | * @param between The smallest value the number can take. 32 | * @param and The biggest value the number can take. 33 | * @return The limited number. 34 | */ 35 | public static int limit(int number, int between, int and) { 36 | if (number <= between) { 37 | return between; 38 | } 39 | if (number >= and) { 40 | return and; 41 | } 42 | return number; 43 | } 44 | 45 | /** 46 | * Limits the given number between the other values 47 | * @param number The number to limit. 48 | * @param between The smallest value the number can take. 49 | * @param and The biggest value the number can take. 50 | * @return The limited number. 51 | */ 52 | public static float limit(float number, float between, float and) { 53 | if (number <= between) { 54 | return between; 55 | } 56 | if (number >= and) { 57 | return and; 58 | } 59 | return number; 60 | } 61 | 62 | public static float max(float number, float max) { 63 | if (number > max) { 64 | return max; 65 | } 66 | return number; 67 | } 68 | 69 | public static float min(float number, float min) { 70 | if (number < min) { 71 | return min; 72 | } 73 | return number; 74 | } 75 | 76 | public static int max(int number, int max) { 77 | if (number > max) { 78 | return max; 79 | } 80 | return number; 81 | } 82 | 83 | public static int min(int number, int min) { 84 | if (number < min) { 85 | return min; 86 | } 87 | return number; 88 | } 89 | 90 | /** 91 | * Methods from libGDX - https://github.com/libgdx/libgdx 92 | */ 93 | 94 | /** Returns the largest integer less than or equal to the specified float. This method will only properly floor floats from 95 | * -(2^14) to (Float.MAX_VALUE - 2^14). */ 96 | static public int floor(float value) { 97 | return (int) (value + BIG_ENOUGH_FLOOR) - BIG_ENOUGH_INT; 98 | } 99 | 100 | /** Returns the smallest integer greater than or equal to the specified float. This method will only properly ceil floats from 101 | * -(2^14) to (Float.MAX_VALUE - 2^14). */ 102 | static public int ceil(float value) { 103 | return (int) (value + BIG_ENOUGH_CEIL) - BIG_ENOUGH_INT; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/PageSizeCalculator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | import com.shockwave.pdfium.util.Size; 19 | import com.shockwave.pdfium.util.SizeF; 20 | 21 | public class PageSizeCalculator { 22 | 23 | private FitPolicy fitPolicy; 24 | private final Size originalMaxWidthPageSize; 25 | private final Size originalMaxHeightPageSize; 26 | private final Size viewSize; 27 | private SizeF optimalMaxWidthPageSize; 28 | private SizeF optimalMaxHeightPageSize; 29 | private float widthRatio; 30 | private float heightRatio; 31 | private boolean fitEachPage; 32 | 33 | public PageSizeCalculator(FitPolicy fitPolicy, Size originalMaxWidthPageSize, Size originalMaxHeightPageSize, 34 | Size viewSize, boolean fitEachPage) { 35 | this.fitPolicy = fitPolicy; 36 | this.originalMaxWidthPageSize = originalMaxWidthPageSize; 37 | this.originalMaxHeightPageSize = originalMaxHeightPageSize; 38 | this.viewSize = viewSize; 39 | this.fitEachPage = fitEachPage; 40 | calculateMaxPages(); 41 | } 42 | 43 | public SizeF calculate(Size pageSize) { 44 | if (pageSize.getWidth() <= 0 || pageSize.getHeight() <= 0) { 45 | return new SizeF(0, 0); 46 | } 47 | float maxWidth = fitEachPage ? viewSize.getWidth() : pageSize.getWidth() * widthRatio; 48 | float maxHeight = fitEachPage ? viewSize.getHeight() : pageSize.getHeight() * heightRatio; 49 | switch (fitPolicy) { 50 | case HEIGHT: 51 | return fitHeight(pageSize, maxHeight); 52 | case BOTH: 53 | return fitBoth(pageSize, maxWidth, maxHeight); 54 | default: 55 | return fitWidth(pageSize, maxWidth); 56 | } 57 | } 58 | 59 | public SizeF getOptimalMaxWidthPageSize() { 60 | return optimalMaxWidthPageSize; 61 | } 62 | 63 | public SizeF getOptimalMaxHeightPageSize() { 64 | return optimalMaxHeightPageSize; 65 | } 66 | 67 | private void calculateMaxPages() { 68 | switch (fitPolicy) { 69 | case HEIGHT: 70 | optimalMaxHeightPageSize = fitHeight(originalMaxHeightPageSize, viewSize.getHeight()); 71 | heightRatio = optimalMaxHeightPageSize.getHeight() / originalMaxHeightPageSize.getHeight(); 72 | optimalMaxWidthPageSize = fitHeight(originalMaxWidthPageSize, originalMaxWidthPageSize.getHeight() * heightRatio); 73 | break; 74 | case BOTH: 75 | SizeF localOptimalMaxWidth = fitBoth(originalMaxWidthPageSize, viewSize.getWidth(), viewSize.getHeight()); 76 | float localWidthRatio = localOptimalMaxWidth.getWidth() / originalMaxWidthPageSize.getWidth(); 77 | this.optimalMaxHeightPageSize = fitBoth(originalMaxHeightPageSize, originalMaxHeightPageSize.getWidth() * localWidthRatio, 78 | viewSize.getHeight()); 79 | heightRatio = optimalMaxHeightPageSize.getHeight() / originalMaxHeightPageSize.getHeight(); 80 | optimalMaxWidthPageSize = fitBoth(originalMaxWidthPageSize, viewSize.getWidth(), originalMaxWidthPageSize.getHeight() * heightRatio); 81 | widthRatio = optimalMaxWidthPageSize.getWidth() / originalMaxWidthPageSize.getWidth(); 82 | break; 83 | default: 84 | optimalMaxWidthPageSize = fitWidth(originalMaxWidthPageSize, viewSize.getWidth()); 85 | widthRatio = optimalMaxWidthPageSize.getWidth() / originalMaxWidthPageSize.getWidth(); 86 | optimalMaxHeightPageSize = fitWidth(originalMaxHeightPageSize, originalMaxHeightPageSize.getWidth() * widthRatio); 87 | break; 88 | } 89 | } 90 | 91 | private SizeF fitWidth(Size pageSize, float maxWidth) { 92 | float w = pageSize.getWidth(), h = pageSize.getHeight(); 93 | float ratio = w / h; 94 | w = maxWidth; 95 | h = (float) Math.floor(maxWidth / ratio); 96 | return new SizeF(w, h); 97 | } 98 | 99 | private SizeF fitHeight(Size pageSize, float maxHeight) { 100 | float w = pageSize.getWidth(), h = pageSize.getHeight(); 101 | float ratio = h / w; 102 | h = maxHeight; 103 | w = (float) Math.floor(maxHeight / ratio); 104 | return new SizeF(w, h); 105 | } 106 | 107 | private SizeF fitBoth(Size pageSize, float maxWidth, float maxHeight) { 108 | float w = pageSize.getWidth(), h = pageSize.getHeight(); 109 | float ratio = w / h; 110 | w = maxWidth; 111 | h = (float) Math.floor(maxWidth / ratio); 112 | if (h > maxHeight) { 113 | h = maxHeight; 114 | w = (float) Math.floor(maxHeight * ratio); 115 | } 116 | return new SizeF(w, h); 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/SnapEdge.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Bartosz Schiller 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | public enum SnapEdge { 19 | START, CENTER, END, NONE 20 | } 21 | -------------------------------------------------------------------------------- /PDocViewer/src/main/java/com/knizha/PDocViewer/util/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Bartosz Schiller. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.knizha.PDocViewer.util; 17 | 18 | import android.content.Context; 19 | import android.util.TypedValue; 20 | 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | 25 | public class Util { 26 | private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; 27 | 28 | public static int getDP(Context context, int dp) { 29 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); 30 | } 31 | 32 | public static byte[] toByteArray(InputStream inputStream) throws IOException { 33 | ByteArrayOutputStream os = new ByteArrayOutputStream(); 34 | byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; 35 | int n; 36 | while (-1 != (n = inputStream.read(buffer))) { 37 | os.write(buffer, 0, n); 38 | } 39 | return os.toByteArray(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable-hdpi/ic_open_in_browser_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable-hdpi/ic_open_in_browser_grey_700_48dp.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable-mdpi/ic_open_in_browser_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable-mdpi/ic_open_in_browser_grey_700_48dp.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable-xhdpi/ic_open_in_browser_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable-xhdpi/ic_open_in_browser_grey_700_48dp.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable-xxhdpi/ic_open_in_browser_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable-xxhdpi/ic_open_in_browser_grey_700_48dp.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable-xxxhdpi/ic_open_in_browser_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable-xxxhdpi/ic_open_in_browser_grey_700_48dp.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable/default_scroll_handle_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable/default_scroll_handle_left.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable/default_scroll_handle_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable/default_scroll_handle_top.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/PDocViewer/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /PDocViewer/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/menu/options.xml: -------------------------------------------------------------------------------- 1 | 2 |

4 | 9 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidPdfViewer demo 3 | Pick file 4 | Unable to pick file. Check status of file manager. 5 | -------------------------------------------------------------------------------- /PDocViewer/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Get the source code 3 | Using submodule [LibPDFium](https://github.com/KnIfER/LibPDFium), which could be compiled within 6 minutes! 4 | 5 | ``` 6 | git clone --recursive --depth=1 https://github.com/KnIfER/PDFium-Android-Demo.git 7 | ``` 8 | 9 | Pdfium source codes (LibPdfium/src/main/PDFIUM) are pulled from AOSP/android11-mainline-release 10 | 11 | Special Thanks: 12 | - `bash-ndk *.mk` buildscripts via [barteksc/modpdfium](https://github.com/barteksc/modpdfium) 13 | 14 | - `cmake` buildscript via [freedom10086/PdfiumAndroid](https://github.com/freedom10086/PdfiumAndroid) 15 | 16 | - `Java & Jni` via [barteksc/AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer) 17 | 18 | 19 | # PDFium Android Demo Viewer 20 | 21 | The beheaviour of this project is just like the original Demo project : *barteksc/AndroidPdfViewer* 22 | 23 | Yet this repo contains **three** build systems : 24 | 25 | 1. **bash-ndk.** 26 | Use : Activate the LibPdfiumSep library module. Then right click on the `jni` folder and select 'Open In Ternimal' in the android studio. Run `ndk-build` and (hopefully) done ! 27 | Develop : To develop the pre-compiled libpdfium.so, prepare win10 and ubuntu subsystem or a real linux system. Then run `./build.sh`. 28 | 29 | 2. **cmake.** 30 | Use / Develop : Activate LibPdfium. Then Just sync and build ! 31 | 32 | 3. **visual studio.** 33 | VS project files are configured by hand. 34 | 35 | # Build libpdfium.so using Visual Studio 36 | Yes, from now on you can build libpdfium.so right in the VS 2019 ! 37 | ### Build times : 38 | - 3:45 minutes, release, -O3, 5.93 MB 39 | - 3:25 minutes, debug, 10.1 MB 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | 2 | buildscript { 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:4.0.0' 9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | org.gradle.jvmargs=-Xmx2048M 3 | android.enableD8=true 4 | android.useAndroidX=true 5 | android.enableJetifier=false 6 | org.gradle.configureondemand = false 7 | android.injected.testOnly=false 8 | 9 | # For more details on how to configure your build environment visit 10 | # http://www.gradle.org/docs/current/userguide/build_environment.html 11 | # 12 | # Specifies the JVM arguments used for the daemon process. 13 | # The setting is particularly useful for tweaking memory settings. 14 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 15 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 16 | # 17 | # When configured, Gradle will run in incubating parallel mode. 18 | # This option should only be used with decoupled projects. More details, visit 19 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 20 | # org.gradle.parallel=true 21 | 22 | ver_compileSdkVersion=android-30 23 | ver_minsdk=19 24 | ver_aimsdk=29 25 | 26 | libs_glide=com.github.bumptech.glide:glide:4.10.0 27 | 28 | libs_compat=androidx.appcompat:appcompat:1.1.0-rc01 29 | libs_mat=com.google.android.material:material:1.1.0-alpha09 30 | libs_recycler=androidx.recyclerview:recyclerview:1.2.0-alpha04 31 | libs_docfile=androidx.documentfile:documentfile:1.0.1 32 | libs_v4=androidx.legacy:legacy-support-v4:1.0.0 33 | use_mat_official= 34 | use_compat_official= 35 | use_prefer_official= 36 | 37 | libs_appres=androidx.appcompat:appcompat-resources:1.1.0-rc01 38 | libs_drawer=androidx.drawerlayout:drawerlayout:1.1.0-alpha02 39 | libs_cursor=androidx.cursoradapter:cursoradapter:1.0.0 40 | libs_fragment=androidx.fragment:fragment:1.2.0-alpha01 41 | 42 | libs_anno=androidx.annotation:annotation:1.0.1 43 | libs_prefer=androidx.preference:preference:1.1.0-rc01 44 | libs_cardview=androidx.cardview:cardview:1.0.0 45 | libs_coordinator=androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01 46 | libs_core=androidx.core:core:1.3.0-rc01 47 | libs_collection=androidx.collection:collection:1.0.0 48 | libs_lifecycle=androidx.lifecycle:lifecycle-runtime:2.0.0 49 | libs_transition=androidx.transition:transition:1.0.1 50 | libs_vectordrawable=androidx.vectordrawable:vectordrawable:1.1.0-rc01 51 | libs_viewpager=androidx.viewpager:viewpager:1.0.0 52 | libs_viewpager2=androidx.viewpager2:viewpager2:1.0.0-beta02 53 | 54 | libs_clang=org.apache.commons:commons-lang3:3.9 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnIfER/PDFium-Android-Demo/18455b7afe57946bd9c458aa9dba63666de0cc5b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 18 01:14:14 CEST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @REM 2 | @REM Copyright 2014 Joan Zapata 3 | @REM 4 | @REM This file is part of Android-pdfview. 5 | @REM 6 | @REM Android-pdfview is free software: you can redistribute it and/or modify 7 | @REM it under the terms of the GNU General Public License as published by 8 | @REM the Free Software Foundation, either version 3 of the License, or 9 | @REM (at your option) any later version. 10 | @REM 11 | @REM Android-pdfview is distributed in the hope that it will be useful, 12 | @REM but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | @REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | @REM GNU General Public License for more details. 15 | @REM 16 | @REM You should have received a copy of the GNU General Public License 17 | @REM along with Android-pdfview. If not, see . 18 | @REM 19 | 20 | @if "%DEBUG%" == "" @echo off 21 | @rem ########################################################################## 22 | @rem 23 | @rem Gradle startup script for Windows 24 | @rem 25 | @rem ########################################################################## 26 | 27 | @rem Set local scope for the variables with windows NT shell 28 | if "%OS%"=="Windows_NT" setlocal 29 | 30 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | set DEFAULT_JVM_OPTS= 32 | 33 | set DIRNAME=%~dp0 34 | if "%DIRNAME%" == "" set DIRNAME=. 35 | set APP_BASE_NAME=%~n0 36 | set APP_HOME=%DIRNAME% 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windowz variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | if "%@eval[2+2]" == "4" goto 4NT_args 72 | 73 | :win9xME_args 74 | @rem Slurp the command line arguments. 75 | set CMD_LINE_ARGS= 76 | set _SKIP=2 77 | 78 | :win9xME_args_slurp 79 | if "x%~1" == "x" goto execute 80 | 81 | set CMD_LINE_ARGS=%* 82 | goto execute 83 | 84 | :4NT_args 85 | @rem Get arguments from the 4NT Shell from JP Software 86 | set CMD_LINE_ARGS=%$ 87 | 88 | :execute 89 | @rem Setup the command line 90 | 91 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 92 | 93 | @rem Execute Gradle 94 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 95 | 96 | :end 97 | @rem End local scope for the variables with windows NT shell 98 | if "%ERRORLEVEL%"=="0" goto mainEnd 99 | 100 | :fail 101 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 102 | rem the _cmd.exe /c_ return code! 103 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 104 | exit /b 1 105 | 106 | :mainEnd 107 | if "%OS%"=="Windows_NT" endlocal 108 | 109 | :omega 110 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':LibPdfiumSep' 2 | include ':PDocViewer' 3 | 4 | --------------------------------------------------------------------------------