项目作者: alaeddinejebali

项目描述 :
How to convert a document to a PDF using iText and Aspose?
高级语言: Java
项目地址: git://github.com/alaeddinejebali/Android-ConvertToPDF.git
创建时间: 2015-04-02T16:41:14Z
项目社区:https://github.com/alaeddinejebali/Android-ConvertToPDF

开源协议:

下载


Using iText

To use the library.

  1. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" ></uses-permission>

Using Aspose

  • The project is “/ConvertToPdf-Aspose/“
  • Download Aspose zip from http://www.aspose.com/community/files/74/android-components/aspose.pdf-for-android/default.aspx
  • When you extract it you’ll find:
  • Add “aspose-words-x.xx-android-jdkxx.jar” to your “lib” folder (with Android-Studio, you may need to right-click the “lib/aspose-words-x.xx-android-jdkxx.jar” -> “Add as Library…”)
  • Add “aw-classes_dex2jar.jar” to your “lib” folder (with Android-Studio, you may need to right-click the “lib/aw-classes_dex2jar.jar” -> “Add as Library…”)
  • Add permission and MultiDex to your AndroidManifest
  1. <application android:name="android.support.multidex.MultiDexApplication"
  2. (...)
  3. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" ></application>
  • Add those lines to your “app/build.gradle”
    ```xml
    (…)

    defaultConfig {

    1. multiDexEnabled true

    }

    (…)

    dexOptions {

    1. javaMaxHeapSize "4g"

    }

    (…)

    dependencies {

    1. provided files('libs/aw-classes_dex2jar.jar')
    2. compile 'com.google.code.gson:gson:2.3'
    3. compile 'com.android.support:multidex:1.0.0'

    }

  1. - Copy/paste "resources" folder to "/main/assets/"
  2. - Convert your files
  3. ```java
  4. try{
  5. Document document = new Document(filePath);
  6. document.save(outputPath);
  7. } catch (Exception e) {
  8. e.printStackTrace();
  9. }