Can't convert pdf file to word file


#1

class com.aspose.pdf.internal.ms.System.ArgumentException: Save a document to a doc format is not supported.


#2

@hardik24895

Could you please make sure that you are using code snippet as given in this example. In case issue still persists, please share your PDF document with us. We will test the scenario in our environment and address it accordingly.


#3

Document pdfDocument = new Document(SdPath + “/sample.pdf”);
pdfDocument.save(SdPath + “/sample.doc”, SaveFormat.Doc);


#4

sample.pdf (3.0 KB)


#5

@hardik24895

Thanks for sharing sample PDF.

Please use following code snippet to convert your PDF document into .doc format using Aspose.PDF for Java 19.4.

Document doc = new Document(dataDir + "sample.pdf");
DocSaveOptions saveOption = new DocSaveOptions();
saveOption.setFormat(DocSaveOptions.DocFormat.Doc);
doc.save(dataDir + "sample.doc", saveOption);

sample.zip (6.7 KB)

Attached is the output .doc file which was generated in our environment without raising any issue. In case of any further assistance, please feel free to let us know.


#6

hi is there any licence required to conversion ? because i m using free version


#7

@hardik24895

Yes, in order to perform conversion without any limitation, you need to use a valid license. In case you do not have one, you can consider applying 30-days free temporary license over our website.


#8

i have applied temporary licence but same problem plz help me

class com.aspose.pdf.internal.ms.System.ArgumentException: Save a document to a doc format is not supported. i have got this error

here is the example

License license = new License();

            InputStream inputStream = getResources().openRawResource(R.raw.license);

            try {
                license.setLicense(inputStream);
            } catch (Exception e) {
                e.printStackTrace();
            }
            Document doc = new Document(new File(selectedPath).getAbsolutePath());
            DocSaveOptions saveOption = new DocSaveOptions();
            saveOption.setFormat(DocSaveOptions.DocFormat.Doc);
            doc.save(Environment.getExternalStorageDirectory().getAbsolutePath() + "/sample.doc", saveOption);

#9

@hardik24895

Please make sure to use latest version i.e. Aspose.PDF for Java 19.5. In case issue still persists, please share a sample console application, which is able to reproduce the issue. We will test the scenario in our environment and address it accordingly.


#10

We have a valid license for Aspose.Words for Android via Java and we wish to have new features with Aspose.Pdf for Android via Java.
I had two types of problems with the same starting code:
String inputPath = Environment.getExternalStorageDirectory (). GetAbsolutePath () + “/ Download / Brochure.pdf”;
String outputPath = Environment.getExternalStorageDirectory (). GetAbsolutePath () + “/ Download / converted_text_aspose.docx”;

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document (inputPath);

now, with pdfDocument.save (outputPath, com.aspose.pdf.SaveFormat.DocX);
I receive the following error:
class com.aspose.pdf.internal.ms.System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
com.aspose.pdf.ADocument.saveInternal (Unknown Source: 8)
com.aspose.pdf.Document.saveInternal (Unknown Source: 0)
com.aspose.pdf.ADocument.save (Unknown Source: 78)
com.aspose.pdf.Document.save (Unknown Source: 0)
com.example.extracttext.MainActivity.ExtractText (MainActivity.java:48)
com.example.extracttext.MainActivity.onCreate (MainActivity.java:59)
android.app.Activity.performCreate (Activity.java:7023)
android.app.Activity.performCreate (Activity.java:7014)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1215)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2734)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2859)
android.app.ActivityThread.-wrap11 (Unknown Source: 0)
android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1592)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6518)
java.lang.reflect.Method.invoke (Native Method)
com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run (RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

but with

com.aspose.pdf.DocSaveOptions saveOption = new com.aspose.pdf.DocSaveOptions ();
saveOption.setFormat (DocSaveOptions.DocFormat.DocX);
pdfDocument.save (OutputPath, saveOption);

I receive the following error:
class com.aspose.pdf.internal.ms.System.ArgumentException: Save a document to a doc format is not supported.
com.aspose.pdf.ADocument.m1 (Unknown Source: 74)
com.aspose.pdf.Document.m1 (Unknown Source: 0)
com.aspose.pdf.ADocument.save (Unknown Source: 38)
com.aspose.pdf.Document.save (Unknown Source: 0)
com.example.extracttext.MainActivity.ExtractText (MainActivity.java:41)
com.example.extracttext.MainActivity.onCreate (MainActivity.java:54)
android.app.Activity.performCreate (Activity.java:7023)
android.app.Activity.performCreate (Activity.java:7014)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1215)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2734)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2859)
android.app.ActivityThread.-wrap11 (Unknown Source: 0)
android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1592)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6518)
java.lang.reflect.Method.invoke (Native Method)
com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run (RuntimeInit.java:438)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:807)

I use the latest version (19.3) of Aspose.PDF
for Android via Java.
On the other hand when i run my code in a Java Application with version (19.8) of Aspose.PDF
for Java, it worked well. No issue at all.
Is there a way to use version (19.8) of Aspose.PDF
for Java in an application running in Android 8.1 device
If no, can you investigate please these issues.
Best Regards


#11

@roro213

Would you kindly share your sample input PDF document with us. We will test the scenario in our environment and address it accordingly.


#12

Hi Asad,
Here are two samples.
Best Regards DocumentConversion.zip (1.8 MB)


#13

Hi,
As i said, i need that it works with version (19.3) of Aspose.PDF
for Android via Java because i’ll use it in Android app.
Version (19.8) of Aspose.PDF works fine in a Java Application but not in Android app.
If i can use (19.8) of Aspose.PDF in Android app successfully as an alternative in case Android version is not working it’ll be great.


#14

Hi,
Is there any update regarding my request?
Best regards


#15

@roro213

We apologize for the delayed response.

We have tested the scenario in our environment and were unable to notice the exception you have shared. However, we did notice that output DOCX file was unable to open in MS Word with an error that document was corrupted.

It seems like API is not creating correct output DOCX and we logged this issue for your both files under following ticket IDs:

  • PDFANDROID-564
  • PDFANDROID-565

We will surely look into details of these issues and keep you posted with the status of their correction. Please spare us little time.

Upcoming Aspose.PDF for Android via Java release will have latest Aspose.PDF for Java library ported into it and as soon as it is available or any update regarding resolution of logged issues is available, we will surely inform you.

We are sorry for the inconvenience faced.


#16

Thanks for your response. Hope compatible version will be released shortly.