We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving a .pdf document as .doc with Aspose.PDF fails

Dear Aspose team,

we have a .pdf file. Saving it with Aspose.PDF as .doc with SaveOptions leads to a ‘System.FormatException: Input string was not in a correct format.’ exception.

Used code:

Aspose.PDF.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions();
saveOptions.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow;

using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputFilePath))
doc.Save(outputFilePath, saveOptions);

Problematic file: Document.pdf (4.4 MB)
Error message: System.FormatException - Input string was not in a correct format…PNG (23.6 KB)
SaveOp[tions: SaveOptions.PNG (81.5 KB)

Could you check out this issue?

Best regards,

Gergely Vándor
[BUG-807]

@gergelyv

We have tested the scenario in our environment using Aspose.PDF for .NET 19.4 and were unable to notice the exception that you have mentioned. For your kind reference, generated document is also attached.
Document.zip (8.3 MB)

However, we did notice that output .docx file has incorrect formatting i.e. text is not placed correctly, images are distorted, etc. Hence, we have logged this issue as PDFNET-46335 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Dear Asad,

We rechecked the problem again with the newest Aspose.Pdf version (19.4 - see AsposeVersion.PNG (88.3 KB) in the attachment), but we are getting the same error message (see ErrorMessage.PNG (84.7 KB)
) ,and a 0 byte sized empty .doc document when we try to save our document with SaveOptions. The code we are using is the following:

        AsposeLicenseInit.AssurePdfLicenseSet();

        Aspose.Pdf.Document doc = new Aspose.Pdf.Document(filePath);
        string fileSavePathWithoutExtension = Path.Combine(new FileInfo(filePath).DirectoryName, 
                                                           Path.GetFileNameWithoutExtension(filePath));
        doc.Save(fileSavePathWithoutExtension + "_SaveWorks.doc", Aspose.Pdf.SaveFormat.Doc);

        Aspose.Pdf.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions();
        saveOptions.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow;
        doc.Save(fileSavePathWithoutExtension + "_SaveFails.doc", saveOptions);

The first save with Save(string outputFileName, SaveFormat format) succeeds, but when we try to save with (and this kind of save is what we need) Save(string outputFileName, SaveOptions options) where we set the RecognitionMode to Flow, and all the rest is as default (we would like to save as .doc - where Format is Aspose.Pdf.DocSaveOptions.DocFormat.Doc, and SaveFormat is Aspose.Pdf.SaveFormat.Doc), we obtain the mentioned error.

Document: Document.pdf (4.4 MB)
Another document where both saves succeed (just as example): SaveWorksWithThisPDF.pdf (481.6 KB)

Would you be so kind and check our problem again?

Best regards,
Gergely Vándor

@gergelyv

Thanks for sharing more details.

We have again tested the scenario in our environment and result were same as they were before. For your kind reference, an output document is also attached.

Document.docx

Therefore, a separate issue as PDFNET-46348 has been logged in our issue tracking system with further details of the exception that you are facing in your environment. We will definitely investigate both logged issues and keep you posted with the status of its correction. Meanwhile, could you please share your environment details e.g. OS name and version, Application Type, etc. with us.

We are sorry for the inconvenience.

Dear @asad.ali,

I am sorry, but I think you are not running the sample code attached above.

The sample file that you are attaching is a .docx, while the sample code wants to save into .doc.

The two important settings are Aspose.Pdf.SaveFormat.Doc and Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow.

Are you sure you have set both of these settings?

Best regards,
Gergely

@gergelyv

You are right. Sorry for the misunderstanding. We were able to reproduce the exception while converting PDF into DOC format instead of DOCX and have updated the information of logged issues as well. As soon as we have some further updates regarding issue resolution, we will surely update you.

We are sorry for the inconvenience.

Thank you for double checking and confirming the issue.