import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.poi.xwpf.converter.pdf.PdfConverter;
import org.apache.poi.xwpf.converter.pdf.PdfOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

public class Main {

    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {
        String docPath = "C:\\Users\\Administrator\\Documents\\Tencent Files\\815703271\\FileRecv\\MobileFile\\shangedaijiekuanxieyi.docx";
        String pdfPath = "C:\\Users\\Administrator\\Documents\\Tencent Files\\815703271\\FileRecv\\MobileFile\\shangedaijiekuanxieyi.pdf";
        XWPFDocument document;
        try (InputStream doc = Files.newInputStream(Paths.get(docPath))) {
            document = new XWPFDocument(doc);
        }
        PdfOptions options = PdfOptions.create();
        try (OutputStream out = Files.newOutputStream(Paths.get(pdfPath))) {
            PdfConverter.getInstance().convert(document, out, options);
        }

    }

}

 

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2021-07-30
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2021-09-06
  • 2022-12-23
  • 2021-11-12
  • 2021-12-30
  • 2021-04-28
  • 2021-08-13
  • 2021-06-18
相关资源
相似解决方案