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()
};
try
{
// Save in word format
doc.Save(newFullFilePath, docSaveOptions);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
// 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!