{"id":32972610,"url":"https://github.com/HendrixString/Android-PdfMyXml","last_synced_at":"2025-11-16T03:01:27.296Z","repository":{"id":31413709,"uuid":"34977056","full_name":"HendrixString/Android-PdfMyXml","owner":"HendrixString","description":"Convert android XML layouts into PDF document, works on all versions of Android.","archived":false,"fork":false,"pushed_at":"2018-05-23T10:41:42.000Z","size":345,"stargazers_count":256,"open_issues_count":2,"forks_count":74,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-10-05T06:07:07.704Z","etag":null,"topics":["android","android-pdfmyxml","pdf","pdf-generation"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HendrixString.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-03T07:06:16.000Z","updated_at":"2025-03-10T06:45:20.000Z","dependencies_parsed_at":"2022-07-28T09:08:55.316Z","dependency_job_id":null,"html_url":"https://github.com/HendrixString/Android-PdfMyXml","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/HendrixString/Android-PdfMyXml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2FAndroid-PdfMyXml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2FAndroid-PdfMyXml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2FAndroid-PdfMyXml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2FAndroid-PdfMyXml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HendrixString","download_url":"https://codeload.github.com/HendrixString/Android-PdfMyXml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HendrixString%2FAndroid-PdfMyXml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284654194,"owners_count":27041729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-pdfmyxml","pdf","pdf-generation"],"created_at":"2025-11-13T05:00:36.453Z","updated_at":"2025-11-16T03:01:27.291Z","avatar_url":"https://github.com/HendrixString.png","language":"Java","readme":"# Android-PdfMyXml [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--PdfMyXml-green.svg?style=flat)](https://android-arsenal.com/details/1/2297) [![Jitpack](https://jitpack.io/v/HendrixString/Android-PdfMyXml.svg)](https://jitpack.io/#HendrixString/Android-PdfMyXml)\nconvert your android `XML` layouts into PDF document, works on all versions of Android.\n\n### Dependencies\n* [`pdfjet`](https://github.com/soster/pdfjet)\n\n## How to use\n\nOption 1: Simply fork or download the project, you can also download and create `.aar` file yourself.\n\nOption 2: Jitpack\n\nAdd Jitpack in your root build.gradle at the end of repositories:\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nAdd to your dependencies:\n\n```groovy\ndependencies {\n    compile 'com.github.HendrixString:Android-PdfMyXml:{Tag}' // the latest version is \"v1.0.1\"\n}\n```\n\n## Notable features\n* should work on all Android versions\n* completely scalable\n* supports bitmap re usage.\n* production proved code. Used in a commercial project.\n\n### Instructions\n#### 1. create XML layouts\nFirst create XML layouts. give it dimensions in **pixels** (and for all it's sub views) and proportions according landscape or portrait according to ratio **1:1.41**.\u003cbr/\u003e\u003cbr/\u003e\npage1.xml\n```java\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cRelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                android:layout_width=\"2115px\"\n                android:layout_height=\"1500px\"\n                android:background=\"@color/white\"\u003e\n  \u003cTextView android:id=\"@+id/tv_hello\"\n                android:textColor=\"@color/black\"\n                android:textSize=\"27px\"\n                android:textStyle=\"bold\"\n                android:padding=\"6px\"/\u003e\n\n\u003c/RelativeLayout\u003e\n```\n\nyou can create as many as pages/templates as you need.\n\n#### 2. Implement a View renderer\nimplement your View renderer by extending `AbstractViewRenderer` or by anonymously instantiating it and injecting the layout id. the initView(View view) will supply you an inflated View automatically. There are other options but I wont cover it now.\n```java\nAbstractViewRenderer page = new AbstractViewRenderer(context, R.layout.page1) {\n    private String _text;\n\n    public void setText(String text) {\n        _text = text;\n    }\n\n    @Override\n    protected void initView(View view) {\n        TextView tv_hello = (TextView)view.findViewById(R.id.tv_hello);\n         tv_hello.setText(_text);\n    }\n};\n\n// you can reuse the bitmap if you want\npage.setReuseBitmap(true);\n\n```\n\n#### 3. Build the PDF document\nUse `PdfDocument` or `PdfDocument.Builder` to add pages and render and run it all at background with progress bar.\n```java\nPdfDocument doc            = new PdfDocument(ctx);\n\n// add as many pages as you have\ndoc.addPage(page);\n\ndoc.setRenderWidth(2115);\ndoc.setRenderHeight(1500);\ndoc.setOrientation(PdfDocument.A4_MODE.LANDSCAPE);\ndoc.setProgressTitle(R.string.gen_please_wait);\ndoc.setProgressMessage(R.string.gen_pdf_file);\ndoc.setFileName(\"test\");\ndoc.setSaveDirectory(_ctx.getExternalFilesDir(null));\ndoc.setInflateOnMainThread(false);\ndoc.setListener(new PdfDocument.Callback() {\n    @Override\n    public void onComplete(File file) {\n        Log.i(PdfDocument.TAG_PDF_MY_XML, \"Complete\");\n    }\n\n    @Override\n    public void onError(Exception e) {\n        Log.i(PdfDocument.TAG_PDF_MY_XML, \"Error\");\n    }\n});\n\ndoc.createPdf(ctx);\n\n```\n\nor use `PdfDocument.Builder`\n```java\nnew PdfDocument.Builder(ctx).addPage(page).orientation(PdfDocument.A4_MODE.LANDSCAPE)\n                         .progressMessage(R.string.gen_pdf_file).progressTitle(R.string.gen_please_wait)\n                         .renderWidth(2115).renderHeight(1500)\n                         .saveDirectory(_ctx.getExternalFilesDir(null));\n                         .filename(\"test\")\n                         .listener(new PdfDocument.Callback() {\n                             @Override\n                             public void onComplete(File file) {\n                                 Log.i(PdfDocument.TAG_PDF_MY_XML, \"Complete\");\n                             }\n\n                             @Override\n                             public void onError(Exception e) {\n                                 Log.i(PdfDocument.TAG_PDF_MY_XML, \"Error\");\n                             }\n                         }).create().createPdf(this);\n```\n\n### Additional Contributors\n* [`Sébastiaan`](https://github.com/se-bastiaan)\n\n### License\nIf you like it -\u003e star or share it with others\n\n```\nCopyright (C) 2016 Tomer Shalev (https://github.com/HendrixString)  \n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n```\n\n### Contact Author\n* [tomer.shalev@gmail.com](tomer.shalev@gmail.com)\n* [Google+ TomershalevMan](https://plus.google.com/+TomershalevMan/about)\n* [Facebook - HendrixString](https://www.facebook.com/HendrixString)\n","funding_links":[],"categories":["Media","Other"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHendrixString%2FAndroid-PdfMyXml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHendrixString%2FAndroid-PdfMyXml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHendrixString%2FAndroid-PdfMyXml/lists"}