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 26 27 <!-- change minSdk if needed--> 28 <minSdk>21</minSdk> 29 <compileSdkVersion>21</compileSdkVersion> 30 31 32 <strings> 33 <intro> 34 <![CDATA[ 35 This sample demonstrates how to use PdfRenderer to display PDF documents on the screen. 36 ]]> 37 </intro> 38 </strings> 39 40 <aapt> 41 <noCompress>pdf</noCompress> 42 </aapt> 43 44 <template src="base"/> 45 46 <metadata> 47 <status>PUBLISHED</status> 48 <categories>UI, Graphics</categories> 49 <technologies>Android</technologies> 50 <languages>Java</languages> 51 <solutions>Mobile</solutions> 52 <level>BEGINNER</level> 53 <icon>screenshots/icon-web.png</icon> 54 <screenshots> 55 <img>screenshots/main.png</img> 56 </screenshots> 57 <api_refs> 58 <android>android.graphics.pdf.PdfRenderer</android> 59 </api_refs> 60 61 <description> 62 <![CDATA[ 63 This sample demonstrates how to display PDF document on screen using 64 the PdfRenderer introduced in Android 5.0 Lollipop. 65 ]]> 66 </description> 67 68 <intro> 69 <![CDATA[ 70 You can now render PDF document pages into bitmap images for printing by using 71 the new [PdfRenderer][1] class. You must specify a [ParcelFileDescriptor][2] 72 that is seekable (that is, the content can be randomly accessed) on which the 73 system writes the the printable content. Your app can obtain a page for 74 rendering with [openPage()][3], then call [render()][4] to turn the opened 75 [PdfRenderer.Page][5] into a bitmap. 76 77 This sample loads the PDF from assets. Contents of assets are compressed by 78 default, but we disable it since PdfRenderer class cannot handle it. 79 80 ```groovy 81 android { 82 aaptOptions { 83 noCompress "pdf" 84 } 85 } 86 ``` 87 88 [1]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html 89 [2]: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html 90 [3]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html#openPage(int) 91 [4]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html#render(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Matrix, int) 92 [5]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.Page.html 93 ]]> 94 </intro> 95 </metadata> 96 97 </sample> 98