iText 文档 - 解析符号



我在安卓应用程序中使用iText来创建pdf。

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

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

这给出了一个错误(文档抽象类 - 无法实例化(。

即使在导入import com.itextpdf.text.Document;之后

它显示了这个东西:

Cannot resolve symbol 'itextpdf'

文档显示为错误。

有什么解决办法吗?

首先必须在gradle属性中添加"compile 'com.itextpdf:itextg:5.5.10'"。

其次,您可以尝试:

  • 退出安卓工作室
  • 备份您的项目
  • 删除所有 .iml 文件和 .idea 文件夹
  • 重新启动 Android Studio 并重新导入您的项目

顺便说一下,您在"项目结构"对话框中看到的错误消息在大多数情况下都不是实际问题。

对于第一个错误,请尝试使用

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();
}

第二

Cannot resolve symbol 'itextpdf'

Android Studio说"无法解析符号",但项目编译

最新更新