Problem converting .docx file to pdf in android

I am working with converting a .docx file to a pdf file. The docx file contains text, images, charts. which must be converted to a pdf file. So I used the code below for my task. But it shows that "Converting to Dalvik format ended with error 1" . I used 15 cans, so for.

  try {
        long start = System.currentTimeMillis();

        // 1) Load DOCX into XWPFDocument
        InputStream is = new FileInputStream(new File(
                "/mnt/sdcard/HelloWorld.docx"));

        XWPFDocument document = new XWPFDocument(is);

        // 2) Prepare Pdf options
        PdfOptions options = PdfOptions.create();

        // 3) Convert XWPFDocument to Pdf
        OutputStream out = new FileOutputStream(new File(
                "/mnt/sdcard/HelloWorld.pdf"));

        PdfConverter.getInstance().convert(document, out, options);

        System.err.println("Generate pdf/HelloWorld.pdf with "
                + (System.currentTimeMillis() - start) + "ms");

    } catch (Throwable e) {
        e.printStackTrace();
    }

I was more searching google, I had a lot of suggestions like project β†’ clean, editing eclipse.ini, changing proguard in sdk, .. everything I tried but no one can help. Can anyone help me or any solution? Thanks.

+4

Source: https://habr.com/ru/post/1527833/


All Articles