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