-5

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...

ngrashia
  • 9,869
  • 5
  • 43
  • 58
r raja
  • 21
  • 5

1 Answers1

0

One reason why you "cant get the output" is because you are providing an incorrect FileOutputStream. You need to be using either:

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • k..leave what I have tried...If you know the code to convert Word to Pd f and Pd f to Word ...Please Share me... – r raja Nov 14 '14 at 04:22