0

I am using iText in android app to create pdf.

 try{

        File file=new File("test.pdf");
        FileOutputStream fileout=new FileOutputStream(file);
        Document document=new Document();


    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

this gives an error (Document abstract class - cannot be instantiated).

Even after importing import com.itextpdf.text.Document;

It shows this thing:

Cannot resolve symbol 'itextpdf'

document is displayed as error.

Any solution?

Joris Schellekens
  • 8,483
  • 2
  • 23
  • 54
echoaman
  • 71
  • 4
  • 15

2 Answers2

0

First have to add "compile 'com.itextpdf:itextg:5.5.10'" in gradle properties.

Second you could try:

  • Exit Android Studio
  • Back up your project
  • Delete all the .iml files and the .idea folder
  • Relaunch Android Studio and re-import your project

By the way, the error messages you see in the Project Structure dialog are not actual issue for the most part.

0

For first error try with

 try{

    File file=new File("test.pdf");
    FileOutputStream fileout=new FileOutputStream(file);
    com.itextpdf.text.Document document=new com.itextpdf.text.Document();


} catch (FileNotFoundException e) {
    e.printStackTrace();
}

Second

Cannot resolve symbol 'itextpdf'

Android Studio says "cannot resolve symbol" but project compiles

Sasikumar Murugesan
  • 4,412
  • 10
  • 51
  • 74