1 Android PdfRendererBasic Sample 2 =================================== 3 4 This sample demonstrates how to display PDF document on screen using 5 the PdfRenderer introduced in Android 5.0 Lollipop. 6 7 Introduction 8 ------------ 9 10 You can now render PDF document pages into bitmap images for printing by using 11 the new [PdfRenderer][1] class. You must specify a [ParcelFileDescriptor][2] 12 that is seekable (that is, the content can be randomly accessed) on which the 13 system writes the the printable content. Your app can obtain a page for 14 rendering with [openPage()][3], then call [render()][4] to turn the opened 15 [PdfRenderer.Page][5] into a bitmap. 16 17 This sample loads the PDF from assets. Contents of assets are compressed by 18 default, but we disable it since PdfRenderer class cannot handle it. 19 20 ```groovy 21 android { 22 aaptOptions { 23 noCompress "pdf" 24 } 25 } 26 ``` 27 28 [1]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html 29 [2]: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html 30 [3]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html#openPage(int) 31 [4]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html#render(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Matrix, int) 32 [5]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html 33 34 Pre-requisites 35 -------------- 36 37 - Android SDK v21 38 - Android Build Tools v21.1.1 39 - Android Support Repository 40 41 Screenshots 42 ------------- 43 44 <img src="screenshots/main.png" height="400" alt="Screenshot"/> 45 46 Getting Started 47 --------------- 48 49 This sample uses the Gradle build system. To build this project, use the 50 "gradlew build" command or use "Import Project" in Android Studio. 51 52 Support 53 ------- 54 55 - Google+ Community: https://plus.google.com/communities/105153134372062985968 56 - Stack Overflow: http://stackoverflow.com/questions/tagged/android 57 58 If you've found an error in this sample, please file an issue: 59 https://github.com/googlesamples/android-PdfRendererBasic 60 61 Patches are encouraged, and may be submitted by forking this project and 62 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. 63 64 License 65 ------- 66 67 Copyright 2014 The Android Open Source Project, Inc. 68 69 Licensed to the Apache Software Foundation (ASF) under one or more contributor 70 license agreements. See the NOTICE file distributed with this work for 71 additional information regarding copyright ownership. The ASF licenses this 72 file to you under the Apache License, Version 2.0 (the "License"); you may not 73 use this file except in compliance with the License. You may obtain a copy of 74 the License at 75 76 http://www.apache.org/licenses/LICENSE-2.0 77 78 Unless required by applicable law or agreed to in writing, software 79 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 80 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 81 License for the specific language governing permissions and limitations under 82 the License. 83