如何使用java api将doc转换为pdf.其中document包含各种格式,如ms中的表格.使用iText转换为pdf时.实际文件看起来与转换后的pdf不同.请提供任何api而不是安装转换的exe.必须是开源的
通过使用apache POI如何将ms word文件转换为pdf?
我使用以下代码,但它没有工作给出错误,我想我正在导入错误的类?
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class TestCon {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
POIFSFileSystem fs = null;
Document document = new Document();
try {
System.out.println("Starting the test");
fs = new POIFSFileSystem(new FileInputStream("/document/test2.doc"));
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
OutputStream …Run Code Online (Sandbox Code Playgroud)