Anyone Know the code for converting Word to PDF / PDF to Word in ANDROID... If you Know Please Share me.... Already tried:
Jars:
docx4j-3.0.0.jar
Code:
try
{
long start = System.currentTimeMillis();
InputStream is = new FileInputStream(
new File("file1"));
Toast.makeText(getApplicationContext(), "is", Toast.LENGTH_SHORT).show();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.load(is);
List sections = wordMLPackage.getDocumentModel().getSections();
for (int i = 0; i < sections.size(); i++) {
System.out.println("sections Size" + sections.size());
/* wordMLPackage.getDocumentModel().getSections().get(i)
.getPageDimensions().setHeaderExtent(3000);*/
}
Mapper fontMapper = new IdentityPlusMapper();
PhysicalFont font = (PhysicalFont) PhysicalFonts.getPhysicalFonts().get(
"Comic Sans MS");
fontMapper.getFontMappings().put("Algerian", font);
wordMLPackage.setFontMapper(fontMapper);
PdfSettings pdfSettings = new PdfSettings();
org.docx4j.convert.out.pdf.PdfConversion conversion = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(
wordMLPackage);
OutputStream out = new FileOutputStream(new File(
"file1/sampleeee.pdf"));
conversion.output(out, pdfSettings);
System.err.println("Time taken to Generate pdf "
+ (System.currentTimeMillis() - start) + "ms");
}
catch(Exception e)
{
e.printStackTrace();
}
But I cant get the output...