Hello i am using docx4j 2.8.0 and converting docx file into pdf file using following code in java
public static void test() throws Exception
{
String docxFile = "E://testData_20120814194757666.docx";
WordprocessingMLPackage pkg = WordprocessingMLPackage.load(new File(docxFile));
pkg.setFontMapper(new IdentityPlusMapper());
org.docx4j.convert.out.pdf.PdfConversion c = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(pkg);
String pdfFile = changeExtensionToPdf(docxFile);
OutputStream os = new FileOutputStream(pdfFile);
c.output(os,new PdfSettings());
os.close();
}
public static String changeExtensionToPdf(String path)
{
int markerIndex = path.lastIndexOf(".docx");
String pdfFile = path.substring(0, markerIndex) + ".pdf";
return pdfFile;
}
public static void main(String[] args)
{
try
{
DocxToPdfTest.test();
}
catch (Exception e)
{
e.printStackTrace();
}
}
it will work fine when i create docx file from word2007 having formated text as well as having image
but when i create my docx file using my service(we are using .net services) it will not me allow to create proper pdf file it will discard the formatted text part