All Projects → HendrixString → Android Pdfmyxml

HendrixString / Android Pdfmyxml

Licence: gpl-2.0
convert android xml layouts into PDF document, works on all versions of Android.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Pdfmyxml

Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (-39.83%)
Mutual labels:  pdf, pdf-generation
Pdf Lib
Create and modify PDF documents in any JavaScript environment
Stars: ✭ 3,426 (+1383.12%)
Mutual labels:  pdf, pdf-generation
Doctron
Docker-powered html convert to pdf(html2pdf), html to image(html2image like jpeg,png),which using chrome(golang) kernel, add watermarks to pdf, convert pdf to images etc.
Stars: ✭ 141 (-38.96%)
Mutual labels:  pdf, pdf-generation
Nimpdf
PDF document writer, written in nim lang
Stars: ✭ 127 (-45.02%)
Mutual labels:  pdf, pdf-generation
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+923.81%)
Mutual labels:  pdf, pdf-generation
Pdfcreatorandroid
Simple library to generate and view PDF in Android
Stars: ✭ 128 (-44.59%)
Mutual labels:  pdf, pdf-generation
Openpdf
OpenPDF is a free Java library for creating and editing PDF files with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository. ⛺
Stars: ✭ 2,174 (+841.13%)
Mutual labels:  pdf, pdf-generation
Ptext Release
pText is a library for reading, creating and manipulating PDF files in python.
Stars: ✭ 124 (-46.32%)
Mutual labels:  pdf, pdf-generation
Resumake.io
📝 A website for automatically generating elegant LaTeX resumes.
Stars: ✭ 2,277 (+885.71%)
Mutual labels:  pdf, pdf-generation
Chrome Headless Render Pdf
Stars: ✭ 164 (-29%)
Mutual labels:  pdf, pdf-generation
Phpchrometopdf
A slim PHP wrapper around google-chrome to convert url to pdf or to take screenshots , easy to use and clean OOP interface
Stars: ✭ 127 (-45.02%)
Mutual labels:  pdf, pdf-generation
Pdf Bot
🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
Stars: ✭ 2,551 (+1004.33%)
Mutual labels:  pdf, pdf-generation
Etherpad Lite
Etherpad: A modern really-real-time collaborative document editor.
Stars: ✭ 11,937 (+5067.53%)
Mutual labels:  pdf, pdf-generation
Pdfinverter
darken (or lighten) a PDF
Stars: ✭ 139 (-39.83%)
Mutual labels:  pdf, pdf-generation
Report
Report management package in PHP that aims to help you export information in a variety of formats
Stars: ✭ 125 (-45.89%)
Mutual labels:  pdf, pdf-generation
Reportbro Designer
Javascript plugin to visually design report layouts (for pdf and Excel) which can be created with reportbro-lib (a Python package) on the server.
Stars: ✭ 160 (-30.74%)
Mutual labels:  pdf, pdf-generation
Play Pdf
A PDF module for the Play framework
Stars: ✭ 108 (-53.25%)
Mutual labels:  pdf, pdf-generation
Labelmake
Declarative style JavaScript PDF generator library. Works on Node and the browser 🖨︎
Stars: ✭ 112 (-51.52%)
Mutual labels:  pdf, pdf-generation
Wasm Pdf
Generate PDF files with JavaScript and WASM (WebAssembly)
Stars: ✭ 163 (-29.44%)
Mutual labels:  pdf, pdf-generation
Pdfgen
Simple C PDF Writer/Generation library
Stars: ✭ 200 (-13.42%)
Mutual labels:  pdf, pdf-generation

Android-PdfMyXml Android Arsenal Jitpack

convert your android XML layouts into PDF document, works on all versions of Android.

Dependencies

How to use

Option 1: Simply fork or download the project, you can also download and create .aar file yourself.

Option 2: Jitpack

Add Jitpack in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add to your dependencies:

dependencies {
    compile 'com.github.HendrixString:Android-PdfMyXml:{Tag}' // the latest version is "v1.0.1"
}

Notable features

  • should work on all Android versions
  • completely scalable
  • supports bitmap re usage.
  • production proved code. Used in a commercial project.

Instructions

1. create XML layouts

First 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.

page1.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="2115px"
                android:layout_height="1500px"
                android:background="@color/white">
  <TextView android:id="@+id/tv_hello"
                android:textColor="@color/black"
                android:textSize="27px"
                android:textStyle="bold"
                android:padding="6px"/>

</RelativeLayout>

you can create as many as pages/templates as you need.

2. Implement a View renderer

implement 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.

AbstractViewRenderer page = new AbstractViewRenderer(context, R.layout.page1) {
    private String _text;

    public void setText(String text) {
        _text = text;
    }

    @Override
    protected void initView(View view) {
        TextView tv_hello = (TextView)view.findViewById(R.id.tv_hello);
         tv_hello.setText(_text);
    }
};

// you can reuse the bitmap if you want
page.setReuseBitmap(true);

3. Build the PDF document

Use PdfDocument or PdfDocument.Builder to add pages and render and run it all at background with progress bar.

PdfDocument doc            = new PdfDocument(ctx);

// add as many pages as you have
doc.addPage(page);

doc.setRenderWidth(2115);
doc.setRenderHeight(1500);
doc.setOrientation(PdfDocument.A4_MODE.LANDSCAPE);
doc.setProgressTitle(R.string.gen_please_wait);
doc.setProgressMessage(R.string.gen_pdf_file);
doc.setFileName("test");
doc.setSaveDirectory(_ctx.getExternalFilesDir(null));
doc.setInflateOnMainThread(false);
doc.setListener(new PdfDocument.Callback() {
    @Override
    public void onComplete(File file) {
        Log.i(PdfDocument.TAG_PDF_MY_XML, "Complete");
    }

    @Override
    public void onError(Exception e) {
        Log.i(PdfDocument.TAG_PDF_MY_XML, "Error");
    }
});

doc.createPdf(ctx);

or use PdfDocument.Builder

new PdfDocument.Builder(ctx).addPage(page).orientation(PdfDocument.A4_MODE.LANDSCAPE)
                         .progressMessage(R.string.gen_pdf_file).progressTitle(R.string.gen_please_wait)
                         .renderWidth(2115).renderHeight(1500)
                         .saveDirectory(_ctx.getExternalFilesDir(null));
                         .filename("test")
                         .listener(new PdfDocument.Callback() {
                             @Override
                             public void onComplete(File file) {
                                 Log.i(PdfDocument.TAG_PDF_MY_XML, "Complete");
                             }

                             @Override
                             public void onError(Exception e) {
                                 Log.i(PdfDocument.TAG_PDF_MY_XML, "Error");
                             }
                         }).create().createPdf(this);

Additional Contributors

License

If you like it -> star or share it with others

Copyright (C) 2016 Tomer Shalev (https://github.com/HendrixString)  

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Contact Author

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].