我正在尝试将文本文件转换为 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);,进程当然会在没有密码的情况下完成,但是一旦这条线在那里,进程就会在此时挂起。我究竟做错了什么?
郎朗坤
相关分类