Practical process
pdf to excel
public static long pdfToExcel(String inFile, String outFile) throws Exception { if (!()) { return 0; } try { long old = (); Document doc = new Document(inFile); ExcelSaveOptions options = new ExcelSaveOptions(); (); (outFile, options); (inFile, outFile, (), old); return new File(outFile).length(); }catch (Exception e) { (); throw new Exception(()); } }
excel to pdf
public static long excelToPdf(String inFile, String outFile) throws Exception { if (!()) { return 0; } try { long old = (); File pdfFile = new File(outFile); Workbook wb = new Workbook(inFile); PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); (true); FileOutputStream fileOS = new FileOutputStream(pdfFile); (fileOS, ); (); long now = (); (inFile, outFile, now, old); return (); }catch (Exception e) { (); throw new Exception(()); } }
ppt to pdf
public static long pptToPdf(String inFile, String outFile) throws Exception { if (!()) { return 0; } try { long old = (); File pdfFile = new File(outFile); FileOutputStream os = new FileOutputStream(pdfFile); Presentation pres = new Presentation(inFile); (os, ); (); long now = (); (inFile, outFile, now, old); return (); } catch (Exception e) { (); throw new Exception(()); } }
pdf to ppt
public static long pdfToPpt(String inFile, String outFile) { if (!()) { return 0; } long old = (); Document pdfDocument = new Document(inFile); PptxSaveOptions pptxOptions = new PptxSaveOptions(); (true); (outFile, pptxOptions); long now = (); (inFile, outFile, now, old); return new File(outFile).length(); }
pdf to word
public static long pdfToDoc(String inFile, String outFile) { if (!()) { return 0; } ("Start the conversion..."); long old = (); Document pdfDocument = new Document(inFile); DocSaveOptions saveOptions = new DocSaveOptions(); /** or*/ (); (outFile, saveOptions); long now = (); (inFile, outFile, now, old); ("Conversion ends..."); return new File(outFile).length(); }
Word to pdf
public static long wordToPdf(String inFile, String outFile) throws Exception { if (!()) { return 0; } try { long old = (); File file = new File(outFile); FileOutputStream os = new FileOutputStream(file); Document doc = new Document(inFile); Document tmp = new Document(); (); (doc, ImportFormatMode.USE_DESTINATION_STYLES); ("Start parsing word documents" + inFile); (os, ); long now = (); ("target file size:{}",()); (); (inFile, outFile, now, old); return (); } catch (Exception e) { (inFile + "Conversion failed, please try again",e); throw new Exception(()); } }
Excel to pictures
public static long excelToPic(String inFile, String outFile) throws Exception { if (!()) { return 0; } try { long old = (); Workbook wb = new Workbook(inFile); Worksheet sheet = ().get(0); ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); (()); (true); (true); SheetRender render = new SheetRender(sheet, imgOptions); (0, outFile); long now = (); (inFile, outFile, now, old); return new File(outFile).length(); }catch (Exception e) { (); throw new Exception(()); } }
pdf to picture
public static long pdfToPng(String inFile, List<String> outFile) throws Exception { long size = 0; if (!()) { return size; } try { long old = (); Document pdfDocument = new Document(inFile); Resolution resolution = new Resolution(960); JpegDevice jpegDevice = new JpegDevice(resolution); for (int index=1;index<=().size();index++) { String path = (0,(".")) + "_"+index+".png"; File file = new File(path); size += (); FileOutputStream fileOs = new FileOutputStream(file); (().get_Item(index), fileOs); (path); (); long now = (); (inFile, path, now, old); } return size; }catch (Exception e){ ((),e); throw new Exception(()); } }
odt to pdf
public static long pdfToPng(String inFile, List<String> outFile) throws Exception { long size = 0; if (!()) { return size; } try { long old = (); Document pdfDocument = new Document(inFile); Resolution resolution = new Resolution(960); JpegDevice jpegDevice = new JpegDevice(resolution); for (int index=1;index<=().size();index++) { String path = (0,(".")) + "_"+index+".png"; File file = new File(path); size += (); FileOutputStream fileOs = new FileOutputStream(file); (().get_Item(index), fileOs); (path); (); long now = (); (inFile, path, now, old); } return size; }catch (Exception e){ ((),e); throw new Exception(()); } }
The above is the detailed content of Android's implementation of excel/pdf/word/odt/image conversion. For more information about Android excel pdf word odt image conversion, please follow my other related articles!