我想用JasperReports和Java生成密碼保護的PDF文件。受密碼保護的PDF Jaspersoft
代碼如下:
jrPdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, path.concat(filename).concat(".pdf"));
jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jprint);
jrPdfExporter.setParameter(JRPdfExporterParameter.OWNER_PASSWORD, "Bancosol123");
jrPdfExporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, "Bancosol123");
jrPdfExporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE);
jrPdfExporter.exportReport();
我利用iText 2.1.7生成PDF,它工作正常,但是當我包括密碼的一部分,我得到了錯誤
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
我包括以下兩個jar:
bcprov-jdk15on-1.47.jar
bcmail-jdk15on-1.47.jar
但問題仍未解決。我讀的地方它可能是一個兼容性問題的iText 2.1.7
所以我刪除的iText 2.1.7,其中包括的iText 5.3.2
現在我有以下錯誤
exception in thread "awt-eventqueue-0" java.lang.noclassdeffounderror: com/lowagie/text/documentexception
爲什麼iText 5.3.2而不是iText 5.5.12? –
'java.lang.noclassdeffounderror:com/lowagie/text/documentexception':這是可以預料的。您需要在所有導入語句中將'com.lowagie'替換爲'com.itextpdf'。 –
_I read somewhere_ - 你在哪裏讀過的?編輯您的文章並添加鏈接。 –