Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- CreatePdf pdf = new CreatePdf();
- System.out.println("start");
- pdf.ConvertToPDF("D:\doctopdf.docx", "D:\Test1.pdf");
- }
- public void ConvertToPDF(String docPath, String pdfPath) {
- try {
- InputStream doc = new FileInputStream(new File(docPath));
- XWPFDocument document = new XWPFDocument(doc);
- PdfOptions options = PdfOptions.create();
- OutputStream out = new FileOutputStream(new File(pdfPath));
- PdfConverter.getInstance().convert(document, out, options);
- System.out.print("Done");
- /*}catch(FileNotFoundException ex){
- System.out.print(ex.getMessage());*/
- }catch(IOException ex){
- System.out.print(ex.getMessage());
- }
- }
Add Comment
Please, Sign In to add comment