Skip to content

Repository files navigation

DesignToPDF

This is an android library which converts any xml design to PDF in the local storage. It is very customizable.

Follow these steps to use this library:

In build.gradle (Project)

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

And then in the other gradle file(may be your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)

dependencies {
	        compile 'com.github.kapilmhr:DesignToPDF:1.0'
          }

How to use

Simply in one line of code!:

DesignPdf.with(MainActivity.this).addView(view).create();

If you want callback

   DesignPdf.with(MainActivity.this).addView(view)
                        .create(new Callback() {
                            @Override
                            public void onSuccess(File file) {
                                Toast.makeText(MainActivity.this, "path: "+file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
                                Log.d("path",file.getAbsolutePath());
                            }

                            @Override
                            public void onError(Exception e) {
                                e.printStackTrace();
                            }
                        });

Customizations

Change Margins

DesignPdf.with(context).setMargins(left,right,top,bottom)

Change Filepath and filename

.setFilePath(filePath,"filename")

Change Multiplier

Initially the screen resolution is taken as the default size so in some case adding multiplier can be quick fix if the height of layout is long and is inside scroll view. Thus it wont fit in A4 size paper so increasing height multiplier would solve. By default its 1. set max to 2

.setHeightnWidthMultiplier(heightmultiplier,wifthmultiplier)

Change height and width

Change height and width of layout to be displayed as per need must be greater than 100

.setHeightnWidth(height, width);

Generate PDF from layout that is not visible to user

(strictly, visiblity should be set to false)

DesignPdf.with(MainActivity.this)
                      .addView(R.layout.test_layout)
                      .setViewVisibilty(false)

About

This is an android library which converts any xml design to PDF in the local storage. It is very customizable.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages