[英]iTextPDF library JAVA - The import com.itextpdf cannot be resolved
I'm creating a simple program in JAVA where there is a button that creates a PDF when clicked. 我正在用JAVA创建一个简单的程序,其中有一个单击按钮可以创建PDF。 I'm using iText JAVA library for generating the PDF.
我正在使用iText JAVA库生成PDF。 I've included iText .jar file in "Java build path" but when I try to import classes of the library i get this error:
The import com.itextpdf.cannot be resolved.
我已经在“ Java构建路径”中包含了iText .jar文件,但是当我尝试导入该库的类时,出现此错误:
The import com.itextpdf.cannot be resolved.
For example: 例如:
import com.itextpdf.text.BaseColor; // The import com.itextpdf.text.BaseColor cannot be resolved
import com.itextpdf.text.Document; // The import com.itextpdf.text.Document cannot be resolved
import com.itextpdf ... // and so on
Try to follow these steps: 尝试按照下列步骤操作:
And now you can select all JARs in that folder:( right click on project folder -> Build Path -> Add External Archives). 现在,您可以选择该文件夹中的所有JAR :(右键单击项目文件夹->构建路径->添加外部档案)。
It depends on whether you are using version 7 or 5 of iText. 这取决于您使用的是iText的版本7还是版本5。 If you're using 7, the packages you will need to import change from
com.itextpdf.*
to com.itext.kernel.*
, com.itext.layout.*
etc. 如果您使用的是7,则需要导入的包将从
com.itextpdf.*
更改为com.itext.kernel.*
, com.itext.layout.*
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.