问题描述
我是iText的新手。这是我使用这个库的第一个项目。
I'm a newbie on iText. This is my first project using this library.
我正在构建一个基本上有一个大表的PDF,在编译时,我发现这个类没有找到错误:找不到org.bouncycastle.asn1.ASN1Primitive的 类文件
I'm building a PDF with essentially a big table on it, and while compiling, i'm getting this Class Not Found error: class file for org.bouncycastle.asn1.ASN1Primitive not found
我很困惑,因为我我只使用基本功能,甚至没有触及PDF签名功能。我该怎么做才能解决这个错误?
I'm confused, since i'm only using the basic functionalities, and didn't even touch the PDF Signing features. What should i do to fix the error?
我正在使用:
- JDK 1.7
- iText 5.3.5
- extrajars 2.2(提供bcmail-jdk15-146.jar,bcprov-jdk15-146.jar和bctsp-jdk15-146.jar)
我只在一个类中使用iText,使用这些导入:
I only using iText inside one class, with these imports:
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
如果有帮助,我想澄清一下,当我在NetBeans中运行项目时,它会编译并且运行得很好。当我尝试将其编译为单个可执行jar文件(包括dist / lib)时出现错误
If it helps, i would like to clarify that when i run the project inside NetBeans, it compiles and runs just fine. The error appears when i try to compile it to a single executable jar file (which includes the dist/lib)
这是出现错误的build.xml目标:
This is build.xml target where the error appears:
<target name="single_jar" depends="jar">
<property name="store.jar.name" value="Final"/>
<property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<delete dir="${store.dir}"/>
<mkdir dir="${store.dir}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
<zipgroupfileset dir="dist" includes="*.jar"/>
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<zip destfile="${store.jar}">
<zipfileset src="${store.dir}/temp_final.jar"
excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/temp_final.jar"/>
</target>
推荐答案
目前的iText版本(自5.3.0起)使用BouncyCastle 1.47但你提供1.46;即使这看起来只是一小步,但这些BC版本之间存在重大变化;任何合理的版本管理都会称之为2.0。
Current iText versions (since 5.3.0) use BouncyCastle 1.47 but you provide 1.46; even though that looks like a small step, there are substantial changes between those BC versions; any sensible version management would have called it 2.0.
请更新依赖项。
这篇关于未找到iText和org.bouncycastle.asn1.ASN1Primitive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!