-2

I am trying to create pdf files in android using itext library. But whenever i run the project, I am getting the following error.

Error:Failed to resolve: com.itextpdf:itextpdf:4.2.2

I have entered the following dependencies in my gradle.

compile 'com.lowagie:itext:4.2.2'
compile 'com.itextpdf:itextg:5.5.9'

Can someone please help in this. I have searched a lot on internet but have found nothing.

  • Possible duplicate of [Dependency error in jasper-reports from itext](https://stackoverflow.com/questions/31314373/dependency-error-in-jasper-reports-from-itext) – Amedee Van Gasse May 24 '17 at 14:31
  • Remove the 4.2.2 dependency. – Amedee Van Gasse May 24 '17 at 14:32
  • After removing com.lowagie:itext:4.2.2 dependancy, I am not able to use PdfWriter , Font and other classes of itext library. To make those things work, I had to import com.lowagie.itext, but after removing that import, I am unable to use above mentioned classes of itext library. – Shehryar Zaheer May 24 '17 at 14:56
  • You need to import `com.itextpdf`, not import `com.lowagie`. All mentioned classes are in `com.itextpdf`. See for yourself in the API docs: http://itextsupport.com/apidocs/itext5/5.5.9/ Post your code if it still does not work. – Amedee Van Gasse May 24 '17 at 15:01
  • I have trued importing com.itextpdf class but i think it has been updated and now it does not contain the mentioned classes. – Shehryar Zaheer May 24 '17 at 15:50
  • Show us your code – Amedee Van Gasse May 24 '17 at 15:52
  • When I add this dependency `compile 'com.itextpdf:itextpdf-5.5.6'`,I am getting the following error `Error:Failed to resolve: com.itextpdf:itextpdf-5.5.6` – Shehryar Zaheer May 24 '17 at 16:54
  • 1
    I am sorry, I forgot something. Show us your code PLEASE. – Amedee Van Gasse May 24 '17 at 18:41
  • Furthermore, please explain why you think something like `compile 'com.lowagie:itext:4.2.2'` should work. While one can argue that there once had been a 4.2.0 version (it was internal, but it existed in publicly accessible version control nonetheless), there never was a version 4.2.1 or 4.2.2 by the iText people. So who told you to use that? – mkl May 24 '17 at 18:59

1 Answers1

0

When you want to create an Android application, you need to use iTextG, so this is correct:

compile 'com.itextpdf:itextg:5.5.9'

However, you are also importing a rogue version of iText that doesn't work on Android:

compile 'com.lowagie:itext:4.2.2'

You need to remove that dependency.

Please compare the package name with my name: Lowagie. I am the original developer of iText, and because of the fact that so many people contacted (or even harassed me) personally with questions about iText, I changed the package names from com.lowagie to com.itextpdf in 2009. That's almost 8 years ago.

If you see my name in your code, then you are doing something wrong. Replace all import com.lowagie instances with import com.itextpdf because I removed my name from the packaged names 8 years ago.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165