java - What can I do to make my program (save as pdf File like Microsoft Excel) -


please, possible make (call) or program same thing when save xls file pdf format. in java program using java api jxl or else

i find example

import officetools.officefile; // officetools.jar  fileinputstream fis = new fileinputstream(new file("test.doc"));  fileoutputstream fos = new fileoutputstream(new file("test.pdf"));  officefile f = new officefile(fis,"localhost","8100", false);  f.convert(fos,"pdf"); 

but required openoffice there else pdf crator on excel changing extension automaticly on program

check example here covert doc, excel, text , images pdf uses itext , apache poi

downlaod itext http://itextpdf.com/

downlaod apache poi http://poi.apache.org/download.html

you can use example below convert microsoft office word file pdf

import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.outputstream;  import com.lowagie.text.document; import com.lowagie.text.documentexception; import com.lowagie.text.paragraph; import com.lowagie.text.pdf.pdfwriter;   import org.apache.poi.hwpf.hwpfdocument; import org.apache.poi.hwpf.extractor.wordextractor;  import org.apache.poi.hwpf.usermodel.range; import org.apache.poi.poifs.filesystem.poifsfilesystem;   public class doctopdf{  public static void main(string[] args) {      poifsfilesystem fs = null;       document document = new document();       try {             fs = new poifsfilesystem(new fileinputstream("d:/test.doc"));             hwpfdocument doc = new hwpfdocument(fs);            wordextractor = new wordextractor(doc);             outputstream file = new fileoutputstream(new file("d:/test.pdf"));            pdfwriter writer = pdfwriter.getinstance(document, file);             range range = doc.getrange();          document.open();            writer.setpageempty(true);            document.newpage();            writer.setpageempty(true);             string[] paragraphs = we.getparagraphtext();            (int = 0; < paragraphs.length; i++) {                 org.apache.poi.hwpf.usermodel.paragraph pr = range.getparagraph(i);               paragraphs[i] = paragraphs[i].replaceall("\\cm?\r?\n", "");            system.out.println("length:" + paragraphs[i].length());            system.out.println("paragraph" + + ": " + paragraphs[i].tostring());             // add paragraph document            document.add(new paragraph(paragraphs[i]));            }             system.out.println("finished");        } catch (exception e) {            e.printstacktrace();        } {                        // close document           document.close();                    }        }   } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -