我正在嘗試將文本文件轉換為 pdf 并在此過程中傳遞密碼。方法是這樣的:public static void convertStatementFiles(File sourceDir, File destDir, String logoImgPath, String backImagePath, String threadId) { log.debug("Attempting File Conversion to PDF........"); FilenameFilter only = new OnlyExt("LST"); String[] filenames = sourceDir.list(only); log.debug("Source Files" + sourceDir.getAbsolutePath()); Config cfg = new Config(); try { for (int k = 0; k < filenames.length; k++) { FileInputStream fs = new FileInputStream(sourceDir.getAbsolutePath() + System.getProperty("file.separator") + filenames[k]); BufferedReader br = new BufferedReader(new InputStreamReader(fs)); String accountNumber; for (int j = 0; j < 11; j++) { br.readLine(); } accountNumber = br.readLine().trim().substring(0, 13); File img = new File(logoImgPath); if (!img.exists()) { FileUtils.writeByteArrayToFile(new File(logoImgPath), cfg.getLogoImage()); } //Get Background Image File backImg = new File(backImagePath); if (!backImg.exists()) { FileUtils.writeByteArrayToFile(new File(backImagePath), cfg.getBackgroundImage()); }如果沒有這條線writer.setEncryption(PdfWriter.ENCRYPTION_AES_128, password, password, PdfWriter.AllowPrinting);,進程當然會在沒有密碼的情況下完成,但是一旦這條線在那里,進程就會在此時掛起。我究竟做錯了什么?
1 回答

郎朗坤
TA貢獻1921條經驗 獲得超9個贊
我想出了問題所在,盡管我應該為可能面臨相同問題的任何人發布答案。問題不在于代碼,而bcprov-jdk
在于類路徑中的庫。我有這個庫的不同版本,當我取出其中一個時,問題就解決了。
添加回答
舉報
0/150
提交
取消