User:Developer j2ee123/sandbox

import com.lowagie.text.Rectangle; import com.lowagie.text.Document; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter;

import java.io.File; import java.io.FileOutputStream; /**	 *	 * @author Edukondalu Avula */	public class ConvertSlidesIntoImages {	 /**	 * This method is used to convert the given file to a PDF format * @param inputFile - Name and the path of the file * @param outputFile - Name and the path where the PDF file to be saved * @param isPictureFile */	 private void createPdf(String inputFile, String outputFile, boolean isPictureFile) {	     /**	      * Set the page size for the image */	    Rectangle pageSize = new Rectangle(1480, 1225); Document pdfDocument = new Document(pageSize); String pdfFilePath = outputFile; try {	        FileOutputStream fileOutputStream = new FileOutputStream(pdfFilePath); PdfWriter writer = null; writer = PdfWriter.getInstance(pdfDocument, fileOutputStream); writer.open; pdfDocument.open; /**	        * Proceed if the file given is a picture file */	         if (isPictureFile) {	         pdfDocument.add(com.lowagie.text.Image.getInstance(inputFile)); }	        /**	         * Proceed if the file given is (.txt,.html,.doc etc) */	        else {	        File file = new File(inputFile); //pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file))); }

pdfDocument.close; writer.close; }	    catch (Exception exception) {	     System.out.println("Document Exception!" + exception); }	 }

public static void main(String args[]) { 		  ConvertSlidesIntoImages  pdfConversion = new ConvertSlidesIntoImages; pdfConversion.createPdf("C:\\suresh\\power.JPG", "C:\\suresh\\sure.pdf", true);

}	}

2nd

import java.io.File;

import org.artofsolving.jodconverter.OfficeDocumentConverter; import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration; import org.artofsolving.jodconverter.office.OfficeManager; public class HelloWorldToPDF { public static void main(String[] args) { // 1) Start LibreOffice in headless mode.       OfficeManager officeManager = null;        try {            officeManager = new DefaultOfficeManagerConfiguration                    .setOfficeHome(new File("C:/Program Files/LibreOffice 3.5"))                    .buildOfficeManager;            officeManager.start;            // 2) Create JODConverter converter OfficeDocumentConverter converter = new OfficeDocumentConverter(                   officeManager); // 3) Create PDF           createPDF(converter);            createPDF(converter);        } finally {            // 4) Stop LibreOffice in headless mode. if (officeManager != null) { officeManager.stop; }       }    }    private static void createPDF(OfficeDocumentConverter converter) { try { long start = System.currentTimeMillis; converter.convert(new File("docx/HelloWorld.docx"), new File( "pdf/HelloWorld.pdf")); System.err.println("Generate pdf/HelloWorld.pdf with "                   + (System.currentTimeMillis - start) + "ms"); } catch (Throwable e) { e.printStackTrace; }   } }