Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public static void main(String[] args) {
  2. CreatePdf pdf = new CreatePdf();
  3. System.out.println("start");
  4. pdf.ConvertToPDF("D:\doctopdf.docx", "D:\Test1.pdf");
  5. }
  6.  
  7. public void ConvertToPDF(String docPath, String pdfPath) {
  8.  
  9. try {
  10. InputStream doc = new FileInputStream(new File(docPath));
  11. XWPFDocument document = new XWPFDocument(doc);
  12. PdfOptions options = PdfOptions.create();
  13. OutputStream out = new FileOutputStream(new File(pdfPath));
  14. PdfConverter.getInstance().convert(document, out, options);
  15. System.out.print("Done");
  16. /*}catch(FileNotFoundException ex){
  17. System.out.print(ex.getMessage());*/
  18. }catch(IOException ex){
  19. System.out.print(ex.getMessage());
  20. }
  21. }
Add Comment
Please, Sign In to add comment