• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2014 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17
18
19
20<sample>
21    <name>PdfRendererBasic</name>
22    <group>UI</group>
23    <package>com.example.android.pdfrendererbasic</package>
24
25    <!-- change minSdk if needed-->
26    <minSdk>21</minSdk>
27
28    <strings>
29        <intro>
30            <![CDATA[
31            This sample demonstrates how to use PdfRenderer to display PDF documents on the screen.
32            ]]>
33        </intro>
34    </strings>
35
36    <aapt>
37        <noCompress>pdf</noCompress>
38    </aapt>
39
40    <template src="base"/>
41
42    <metadata>
43        <status>PUBLISHED</status>
44        <categories>UI, Graphics</categories>
45        <technologies>Android</technologies>
46        <languages>Java</languages>
47        <solutions>Mobile</solutions>
48        <level>BEGINNER</level>
49        <icon>screenshots/icon-web.png</icon>
50        <screenshots>
51            <img>screenshots/main.png</img>
52        </screenshots>
53        <api_refs>
54            <android>android.graphics.pdf.PdfRenderer</android>
55        </api_refs>
56
57        <description>
58<![CDATA[
59This sample demonstrates how to display PDF document on screen using
60the PdfRenderer introduced in Android 5.0 Lollipop.
61]]>
62        </description>
63
64        <intro>
65<![CDATA[
66You can now render PDF document pages into bitmap images for printing by using
67the new [PdfRenderer][1] class. You must specify a [ParcelFileDescriptor][2]
68that is seekable (that is, the content can be randomly accessed) on which the
69system writes the the printable content. Your app can obtain a page for
70rendering with [openPage()][3], then call [render()][4] to turn the opened
71[PdfRenderer.Page][5] into a bitmap.
72
73This sample loads the PDF from assets. Contents of assets are compressed by
74default, but we disable it since PdfRenderer class cannot handle it.
75
76```groovy
77android {
78    aaptOptions {
79        noCompress "pdf"
80    }
81}
82```
83
84[1]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html
85[2]: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html
86[3]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html#openPage(int)
87[4]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html#render(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Matrix, int)
88[5]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html
89]]>
90        </intro>
91    </metadata>
92
93</sample>
94