简体   繁体   English

iTextPDF库JAVA-导入com.itextpdf无法解析

[英]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: 尝试按照下列步骤操作:

  • Clean Your Eclipse Project: Go to Project > Clean in Eclipse (in menu above). 清理您的Eclipse项目:转到“项目”>“在Eclipse中清理”(在上面的菜单中)。
  • Refresh your project folder: (right click on your project > refresh). 刷新您的项目文件夹:(右键单击您的项目>刷新)。
  • Re-build your project. 重新生成您的项目。

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.

相关问题 iText 库在 Visual Studio Code 中的错误代码“导入 com.itextpdf 无法解析”。 如何在vscode中导入库? - iText library's error code "The import com.itextpdf cannot be resolved" in Visual Studio Code. How to import library's in vscode? 将ImportPackage com.itextpdf导入XPages中的Java类 - ImportPackage com.itextpdf into a Java Class in XPages com.itextpdf:book:war:5.3.1-SNAPSHOT:无法解决以下工件: - com.itextpdf:book:war:5.3.1-SNAPSHOT: The following artifacts could not be resolved: com.itextpdf.text.pdf.PdfPKCS7库不存在于Java IText中 - com.itextpdf.text.pdf.PdfPKCS7 library not present in java IText 无法在 com.itextpdf:itext7-core:pom:RELEASE 收集依赖项 - Failed to collect dependencies at com.itextpdf:itext7-core:pom:RELEASE Itextpdf库教程上的java.io.FileNotFoundException - java.io.FileNotFoundException on Itextpdf Library tutorial 动态jasper或jasper报告不适用于maven依赖项:无法读取com.itextpdf:itext-pdfa:jar:5.5.0的工件描述符 - dynamic jasper or jasper reporting does not work with maven dependency: Failed to read artifact descriptor for com.itextpdf:itext-pdfa:jar:5.5.0 无法导入com.itextpdf.text.pdf.PdfReader - Could not import com.itextpdf.text.pdf.PdfReader 我无法导入com.itextpdf.text.Document类 - I can't import com.itextpdf.text.Document class 在itextpdf java中对齐单元格 - align cell in itextpdf java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM