aspose-pdf / Aspose.PDF-for-Android-via-java

Aspose.PDF for Android via Java Examples
https://products.aspose.com/pdf/android-java
MIT License
20 stars 12 forks source link

Android Aspose.PDF转档格式不支持问题 #5

Open chiyan171 opened 5 years ago

chiyan171 commented 5 years ago
public static final int None = 0;
public static final int Doc = 1;
public static final int Xps = 2;
public static final int Html = 3;
public static final int Xml = 4;
public static final int TeX = 5;
public static final int DocX = 6;
public static final int Svg = 7;
public static final int MobiXml = 8;
public static final int Excel = 9;
public static final int Epub = 10;
public static final int Plugin = 11;
public static final int Pptx = 14;

但是实际在转档的过程中,错误提示不支持: class com.aspose.pdf.internal.ms.System.ArgumentException: Save a document to a doc format is not supported.

核心code:

                inputStream = getContext().getAssets().open("Aspose.Pdf.lic");
                License license = new License();
                license.setLicense(inputStream);
                if (Document.isLicensed()) {
                    Document document = new Document(path);
                    String path_pre = sd卡路径 + "/aspose_output.doc";
                    document.save(path_pre, SaveFormat.Doc);
                }

jar版本信息: aspose-pdf-18.6-android.via.java.jar

希望贵方能确认,并尽快回复。 是否Android支持贵方列出来的所有格式。 邮箱联系方式:1627524135@qq.com

farhan-raza commented 5 years ago

@chiyan171, Please try using below code snippet in your environment and then share your kind feedback with us.

Document doc = new Document(path); DocSaveOptions saveOptions = new DocSaveOptions(); saveOptions.setFormat(SaveFormat.Doc); doc.save("sd卡路径 + "/aspose_output.doc");

In case the problem persists then share your sample file with us so that we may investigate further to help you out.

PS: I work with Aspose as Developer Evangelist.

chiyan171 commented 5 years ago

您好,非常感谢贵方给予及时的回复;但是目前仍然存在问题:

开发环境:Android Studio;aspose-pdf-18.6-android.via.java.jar;Aspose.Pdf.lic; 执行Code:

            String inputPath = (String) event.getEvent();
            InputStream inputStream = null;
            try {
                inputStream = getContext().getAssets().open("Aspose.Pdf.lic");
                License license = new License();
                license.setLicense(inputStream);
                if (Document.isLicensed()) {
                    Document doc = new Document(inputPath);
                    DocSaveOptions saveOptions = new DocSaveOptions();
                    saveOptions.setFormat(SaveFormat.DocX);
                    File outFile = new File(PathManager.getInstance().getSDCardPathByEnvironment(), "aspose_output.docx");
                    doc.save(outFile.getAbsolutePath());
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                CloseUtils.closeIO(inputStream);
            }

目前只测试了PDF-> DOC,DOCX的两种格式转换,结果成功并输出目标文档到制定目录; 但是生成的文档,不兼容Microsoft doc,打开的文档内容全部乱码;

希望贵方能解决予以回复;或者可以提供贵方邮箱,我把测试文档&结果文档已邮件的方式发送给贵方;谢谢

farhan-raza commented 5 years ago

我们很高兴知道您能够转换文件。 请将源文件和生成的文件发送至farhan.raza@aspose.com,以便我们进一步帮助您。