aspose pdf 17.8.jar
import com.aspose.pdf.Document; import com.aspose.pdf.License; import com.aspose.pdf.SaveFormat; import org.aspectj.util.FileUtil; import lombok.extern.slf4j.Slf4j; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.nio.charset.StandardCharsets; /** * @author *** */ @Slf4j public class PdfToWord { public static void main(String[] args) { pdfToWord("D:\\文档\\面试资料\\Dubbo面试及答案(上).pdf", "C:\\Users\\***\\Desktop\\test.docx"); } private static String pdfToWord(String docPathAndName, String pdfPathAndName) { try (ByteArrayInputStream in = new ByteArrayInputStream(FileUtil.readAsByteArray(new File(docPathAndName))); ByteArrayOutputStream out = new ByteArrayOutputStream(); FileOutputStream fos = new FileOutputStream(pdfPathAndName)) { getLicense(); Document document = new Document(in); document.save(out, SaveFormat.DocX); fos.write(out.toByteArray()); fos.flush(); return pdfPathAndName; } catch (Exception e) { log.error(e.getMessage()); } return pdfPathAndName; } private static void getLicense() { try { String licenseStr = "\n" + " \n" + " \n" + " Aspose.Total for Java\n" + " Aspose.Pdf for Java\n" + " \n" + " Enterprise\n" + " 20991231\n" + " 20991231\n" + " 8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7\n" +
暂无评论