在android中将.docx转换为pdf文件时出现问题

时间:2014-02-20 06:58:10

标签: java android eclipse pdf

我正在将.docx文件转换为pdf文件。 docx文件包含文本,图像,图表。必须转换为pdf文件。所以我使用下面的代码来完成我的任务。但是,它显示“转换为Dalvik格式失败,错误1”我使用了15个罐子。

  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();
    }

我更多地浏览谷歌,我有很多建议,比如项目 - >干净,编辑eclipse.ini,改变sdk中的proguard,.. 我尝试的一切,但没有人可以提供帮助。 任何人都可以帮助我或任何解决方案吗?感谢。

0 个答案:

没有答案