File tree Expand file tree Collapse file tree
src/main/java/com/doctopdf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 <dependency >
2626 <groupId >org.apache.poi</groupId >
2727 <artifactId >poi</artifactId >
28- <version >3.12 </version >
28+ <version >3.17 </version >
2929 </dependency >
3030
3131 <dependency >
3232 <groupId >org.apache.poi</groupId >
3333 <artifactId >poi-ooxml</artifactId >
34- <version >3.12 </version >
34+ <version >3.17 </version >
3535 </dependency >
3636
3737 <dependency >
3838 <groupId >fr.opensagres.xdocreport</groupId >
39- <artifactId >org.apache.poi.xwpf. converter.pdf </artifactId >
40- <version >1 .0.5 </version >
39+ <artifactId >fr.opensagres.xdocreport. converter</artifactId >
40+ <version >2 .0.1 </version >
4141 </dependency >
4242
4343 <dependency >
4444 <groupId >org.apache.poi</groupId >
4545 <artifactId >poi-scratchpad</artifactId >
46- <version >3.12 </version >
46+ <version >3.17 </version >
4747 </dependency >
4848
4949 <dependency >
Original file line number Diff line number Diff line change 1111public class App {
1212 public static void main (String [] args ) throws Exception {
1313
14- String inPath = "C:\\ Users\\ ankur.singhal\\ Desktop\\ testing\\ Keshav-Resume.docx " ;
14+ String inPath = "C:\\ Users\\ ankur.singhal\\ Desktop\\ testing\\ AOPT_Payment_Plan_Addendum_12-10-2017.doc " ;
1515 String lowerCaseInPath = inPath .toLowerCase ();
1616
1717 InputStream inStream = getInFileStream (inPath );
18- OutputStream outStream = getOutFileStream ("C:\\ Users\\ ankur.singhal\\ Desktop\\ testing\\ Keshav-Resume.pdf" );
18+ OutputStream outStream = getOutFileStream (
19+ "C:\\ Users\\ ankur.singhal\\ Desktop\\ testing\\ AOPT_Payment_Plan_Addendum_12-10-2017.pdf" );
1920
2021 if (lowerCaseInPath .endsWith ("doc" )) {
2122 DocToPDFConverter .DocToPDFConvert (inStream , outStream );
Original file line number Diff line number Diff line change 44import java .io .InputStream ;
55import java .io .OutputStream ;
66
7- import org .apache .poi .xwpf .converter .pdf .PdfConverter ;
8- import org .apache .poi .xwpf .converter .pdf .PdfOptions ;
9- import org .apache .poi .xwpf .usermodel .XWPFDocument ;
7+ import fr .opensagres .xdocreport .converter .ConverterRegistry ;
8+ import fr .opensagres .xdocreport .converter .ConverterTypeTo ;
9+ import fr .opensagres .xdocreport .converter .IConverter ;
10+ import fr .opensagres .xdocreport .converter .Options ;
11+ import fr .opensagres .xdocreport .converter .XDocConverterException ;
1012
1113public class DocxToPDFConverter {
1214
13- public static void DocxToPDFConvert (InputStream inStream , OutputStream outStream ) throws IOException {
15+ public static void DocxToPDFConvert (InputStream inStream , OutputStream outStream )
16+ throws IOException , XDocConverterException {
1417
15- XWPFDocument document = new XWPFDocument (inStream );
16- PdfOptions options = PdfOptions .create ();
17- PdfConverter .getInstance ().convert (document , outStream , options );
18+ Options options = Options .getTo (ConverterTypeTo .PDF );
19+ IConverter converter = ConverterRegistry .getRegistry ().getConverter (options );
20+
21+ converter .convert (inStream , outStream , options );
1822 }
1923}
You can’t perform that action at this time.
0 commit comments