# AndroidPDFViewer **Repository Path**: afra55/android-pdfviewer ## Basic Information - **Project Name**: AndroidPDFViewer - **Description**: 安卓PDF预览 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-27 - **Last Updated**: 2023-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AndroidPDFViewer ## 介绍 安卓PDF预览, 修改与2023.11.27,适配 gradle-8.0。 基于 https://github.com/barteksc/AndroidPdfViewer 和 https://github.com/johngray1965/PdfiumAndroidKt/tree/main ## 使用 ``` ``` ``` pdfView.fromUri(Uri) or pdfView.fromFile(File) or pdfView.fromBytes(byte[]) or pdfView.fromStream(InputStream) // stream is written to bytearray - native code cannot use Java Streams or pdfView.fromSource(DocumentSource) or pdfView.fromAsset(String) .pages(0, 2, 1, 3, 3, 3) // all pages are displayed by default .enableSwipe(true) // allows to block changing pages using swipe .swipeHorizontal(false) .enableDoubletap(true) .defaultPage(0) // allows to draw something on the current page, usually visible in the middle of the screen .onDraw(onDrawListener) // allows to draw something on all pages, separately for every page. Called only for visible pages .onDrawAll(onDrawListener) .onLoad(onLoadCompleteListener) // called after document is loaded and starts to be rendered .onPageChange(onPageChangeListener) .onPageScroll(onPageScrollListener) .onError(onErrorListener) .onPageError(onPageErrorListener) .onRender(onRenderListener) // called after document is rendered for the first time // called on single tap, return true if handled, false to toggle scroll handle visibility .onTap(onTapListener) .onLongPress(onLongPressListener) .enableAnnotationRendering(false) // render annotations (such as comments, colors or forms) .password(null) .scrollHandle(null) .enableAntialiasing(true) // improve rendering a little bit on low-res screens // spacing between pages in dp. To define spacing color, set view background .spacing(0) .autoSpacing(false) // add dynamic spacing to fit each page on its own on the screen .linkHandler(DefaultLinkHandler) .pageFitPolicy(FitPolicy.WIDTH) // mode to fit pages in the view .fitEachPage(false) // fit each page to the view, else smaller pages are scaled relative to largest page. .pageSnap(false) // snap pages to screen boundaries .pageFling(false) // make a fling change only a single page like ViewPager .nightMode(false) // toggle night mode .load(); ``` ## 文档加载来源 ``` pdfView.fromUri(Uri) pdfView.fromFile(File) pdfView.fromBytes(byte[]) pdfView.fromStream(InputStream) pdfView.fromAsset(String) ``` ## License ``` Copyright 2017 Bartosz Schiller Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```