How To Add Android Pdf Writer To Android Project
Solution 1:
There is no jar file. You have to embed source files directly. You should include all the source files except for:
- APW.pdf
- PDFWriterDemo.java
- assets.zip
- helloworld.pdf
- README.txt
You don't need any additional jar file.
I write detailed instruction here: http://karino2.livejournal.com/293016.html
Solution 2:
(Using AS 1.2 Beta at time of writing)
You first need to download the source code since there is no jar. To do that:
- Go to the link that you provided and click on "Download Snapshot".
- Unzip the file you just downloaded into a new folder
- Remove all of the files that are not Java files (they aren't necessary)
Then, to add it to your project, it depends on if you are using Gradle.
- With Gradle
- In Android Studio, click on Project Settings
- Click on the plus sign to add a new module
- Click on Android Library
- Choose whatever name you want for the application and module name (AndroidPDFWriter is pretty consistent) but make sure that the package name matches the library's package name (crl.android.pdfwriter)
- Choose No Activity on the next page and press finish to create the module.
- Copy the sources from the folder with the source code into that new module (make sure to copy it in the right directory, i.e. src/main/java/crl.android.pdfwriter)
From there, an Android module is created with all of the necessary resources. I chose to delete all of the extra file that AS creates for you but that's your call. Make sure to keep the manifest (I emptied it though to just have the Manifest tag since nothing else was useful). You can then declare the dependency on this module from your main one like you would normally.
- Without Gradle
- In Android Studio, click on Project Settings
- On the modules page, click on the plus sign to add a new module
- Click on Import Module
- Choose the folder with all of the sources that you had unzipped.
- Go through the following pages of the import module process normally.
From there, the Android module is created (make sure that the Module SDK is an Android one) and you can add a dependency the normal way as well.
This isn't the best way to do things, but I see no alternative for this particular library. Hope this helps !
Solution 3:
Get the jar file and add to your project. Just adding PDFWriterDemo.java will not work as this class has dependency on other classes like Page and you might have to include all of them.
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile files('libs/xyz.jar') } Assuming you are using Android Studio, follow these steps to include .jar into project:
- Get the jar file.
- Put the jar into the libs folder
- Right click it and hit 'Add as library'
- Ensure that compile files is in your build.gradle file, in the dependencies add the below.
.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/xyz.jar')//xyz.jar is the filename of your jar
}
Post a Comment for "How To Add Android Pdf Writer To Android Project"