Import itext-7 in android gradle

The root artifact is a mere parent pom and does not contain iText 7 classes at all.

If you want to include all iText 7 Core functionality, you should try

compile 'com.itextpdf:itext7-core:7.0.2'

If this does not work out of the box (e.g. due to missing Java classes in Android), or if you simply want a leaner installation, note that in contrast to iText 5 the newer iText 7 is not distributed as one big jar but as a set of modules.

For Maven you would use the following dependencies (or more likely a subset from them); you can easily build gradle compile statements from them:

<dependencies>

    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>kernel</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>io</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>layout</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for forms -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>forms</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for PDF/A -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>pdfa</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for digital signatures -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>sign</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for barcodes -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>barcodes</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for Asian fonts -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>font-asian</artifactId>
        <version>7.0.2</version>
    </dependency>

    <!-- only needed for hyphenation -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>hyph</artifactId>
        <version>7.0.2</version>
    </dependency>

</dependencies>

(Getting started with iText 7 on developers.itextpdf.com)

As for Android: currently iText 7 is not compatible with Android and you will get compilation errors iText 7 works out of the box when used on a device with an Android API level 24 or higher (Android Nougat). If you would like to support devices that run on a lower version of Android you could write a Xamarin app, which will run on any version of Android, but Xamarin means writing in .NET.


You need to add

compile 'com.itextpdf:io:7.0.2'
compile 'com.itextpdf:kernel:7.0.2'
compile 'com.itextpdf:layout:7.0.2'

and maybe more, depending on which components you might need. See http://developers.itextpdf.com/itext-7 for the full list - it's in Maven XML format but you should be able to adapt for Gradle.

As for Android: currently iText 7 is not compatible with Android and you will get compilation errors iText 7 works out of the box when used on a device with an Android API level 24 or higher (Android Nougat). If you would like to support devices that run on a lower version of Android you could write a Xamarin app, which will run on any version of Android, but Xamarin means writing in .NET.