• 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    <template src="base"/>
37
38    <metadata>
39        <status>PUBLISHED</status>
40        <categories>UI, Graphics</categories>
41        <technologies>Android</technologies>
42        <languages>Java</languages>
43        <solutions>Mobile</solutions>
44        <level>BEGINNER</level>
45        <icon>screenshots/icon-web.png</icon>
46        <screenshots>
47            <img>screenshots/main.png</img>
48        </screenshots>
49        <api_refs>
50            <android>android.graphics.pdf.PdfRenderer</android>
51        </api_refs>
52
53        <description>
54<![CDATA[
55This sample demonstrates how to display PDF document on screen using
56the PdfRenderer introduced in Android 5.0 Lollipop.
57]]>
58        </description>
59
60        <intro>
61<![CDATA[
62You can now render PDF document pages into bitmap images for printing by using
63the new [PdfRenderer][1] class. You must specify a [ParcelFileDescriptor][2]
64that is seekable (that is, the content can be randomly accessed) on which the
65system writes the the printable content. Your app can obtain a page for
66rendering with [openPage()][3], then call [render()][4] to turn the opened
67[PdfRenderer.Page][5] into a bitmap.
68
69This sample loads the PDF from assets. Contents of assets are compressed by
70default, and the PdfRenderer class cannot open it. In this sample, we work
71around this by copying the file into the cache directory.
72
73[1]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html
74[2]: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html
75[3]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html#openPage(int)
76[4]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html#render(android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.Matrix,%20int)
77[5]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html
78
79]]>
80        </intro>
81    </metadata>
82
83</sample>
84