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

Free Support Forum - aspose.com

Exception when converting PDF to Docx

I am trying to convert a PDF file (which was generated using Aspose) back to a word document, but I keep getting an Object Reference Not Set exception and I can’t work out the reason.

        new License().SetLicense("C:\\Licenses\\Aspose\\Aspose.PDF.NET.lic");

        var newFileName = "TestOutput.docx";

        var tempFilePath = "C:\\Temp\\";
        var newFullFilePath = Path.Combine(tempFilePath, newFileName);

        // Load the file to be converted
        var doc = new Document("C:\\Temp\\TCTest.pdf");
        var docSaveOptions = new DocSaveOptions
            CloseResponse = true,
            Format = DocSaveOptions.DocFormat.DocX,
            WarningHandler = new ConversionWarnings()

            // Save in word format
            doc.Save(newFullFilePath, docSaveOptions);
        catch (Exception e)

        // Get the new base64 out to save
        var newBase64 = Convert.ToBase64String(File.ReadAllBytes(newFullFilePath));

        File.WriteAllBytes(newFullFilePath, Convert.FromBase64String(newBase64));

It doesn’t even hit the catch exception line, if I continue through the exception it does seem to create a document which looks almost right, but I am not sure how to get rid of the exception.
It also doesn’t show me any warnings in the warninghandler callback.

The PDF file I am trying to convert: TCTest.pdf (264.5 KB)

Any help greatfully received!


We have tested the scenario using the latest version of Aspose.PDF for .NET 22.2 and have not found the shared issue. So, please use Aspose.PDF for .NET 22.2. We have attached the output DOCX with this post for your kind reference.
22.2.zip (221.2 KB)

Really strange, I am using the same version, I put my code on a live server anyway and it seems to be ok, only really breaks when running locally.
Very odd


Could you please share your working environment e.g. operating system, .NET version etc. on which Aspose.PDF does not work?

I am using windows 10 enterprise with .NET Framework 4.7.2


We tested the scenario at same environment and have not faced any issue. We only commented following line of code. Please make sure that you are using the same input PDF.