Java:à l'aide d'apache POI, comment convertir le fichier ms word au format pdf?

En utilisant apache POI comment convertir ms word fichier à pdf?

Je un en utilisant le code suivant mais sa ne fonctionne pas donner erreurs je suppose que je suis l'importation de la mauvaise classes?

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class TestCon {
/**
* @param args
*/
public static void main(String[] args) {
//TODO Auto-generated method stub
POIFSFileSystem fs = null;  
Document document = new Document(); 
try {  
System.out.println("Starting the test");  
fs = new POIFSFileSystem(new FileInputStream("/document/test2.doc"));  
HWPFDocument doc = new HWPFDocument(fs);  
WordExtractor we = new WordExtractor(doc);  
OutputStream file = new FileOutputStream(new File("/document/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();  
for (int i = 0; i < paragraphs.length; i++) {  
org.apache.poi.hwpf.usermodel.Paragraph pr = range.getParagraph(i);
//CharacterRun run = pr.getCharacterRun(i);
//run.setBold(true);
//run.setCapitalized(true);
//run.setItalic(true);
paragraphs[i] = paragraphs[i].replaceAll("\\cM?\r?\n", "");  
System.out.println("Length:" + paragraphs[i].length());  
System.out.println("Paragraph" + i + ": " + paragraphs[i].toString());  
//add the paragraph to the document  
document.add(new Paragraph(paragraphs[i]));  
}  
System.out.println("Document testing completed");  
} catch (Exception e) {  
System.out.println("Exception during test");  
e.printStackTrace();  
} finally {  
//close the document  
document.close();  
}  
}  
}
Bonjour Denis, quand j'essaie de convertir fichier word en pdf j'ai eu de la jachère d'erreur dans l'import com.lowagie.texte.Document; import com.lowagie.texte.DocumentException; import com.lowagie.texte.Paragraphe; import com.lowagie.texte.pdf.PdfWriter; s'il vous plaît dites-moi à la bibliothèque j'ai oublié de l'ajouter aussi si c'est possible de me donner un lien pour le téléchargement

OriginalL'auteur Harinder | 2011-06-01