0
我正在试图在JAVA中创建一个自动化程序。 我有一个示例doc文件。我需要填写空白部分或<>来自数据库的“签名”部分, 比创建pdf文件。JAVA阅读示例doc文件,填写数据并生成PDF
我试着读单词:
import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class ReadDocFile {
public static void main(String[] args) {
File file = null;
WordExtractor extractor = null ;
try {
file = new File("c:\\New.doc");
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
HWPFDocument document=new HWPFDocument(fis);
extractor = new WordExtractor(document);
String [] fileData = extractor.getParagraphText();
for(int i=0;i<fileData.length;i++){
if(fileData[i] != null)
System.out.println(fileData[i]);
}
}
catch(Exception exep){}
}
}
但这attemption在许多方式造成不好的,我只需要编写一些部件,这种方法使从DOC单个测试。
所以,你可以咨询我一些API,在一个Word文档例如写:after Name :
或in the 5 row write this:
而当它与字完成它应该产生一个pdf,做一遍......
我找一个解决方案,我发现xssfworkbook与一些额外的功能(生成文档的PDF)。
或阅读样本pdf并填入数据并保存为新的pdf。
THX
,你能告诉我你的进口,它总是给我一些错误,从来没有读过任何东西总是停在wordextractor – Csanesz 2014-10-29 14:47:45
我已编辑我的文章,并添加我的导入。 – stacky 2014-10-29 15:55:18