Hello,
I am using the trial version of GroupDocs.Conversion to convert a PDF file to DOCX. However, when I try to open the output file using MSWord, I get the popup that the file seems to corrupt. Please note that I am able to recover the file, and it seems to be perfectly fine. But, for my application, I cannot afford to have a corrupt file generated. Furthermore, when I convert from PDF to Doc, the output file also has no issues. Please find a snapshot of my code below:-
private byte[] ConvertPDFToWordXGroupDoc(byte[] bytePDF)
{
byte[] bytWordX = null;
try
{
string testPagesPath = System.Web.HttpRuntime.AppDomainAppPath + “\TestPages\”;
Stream streamPDF = new MemoryStream(bytePDF);
GroupDocs.Conversion.License license = new GroupDocs.Conversion.License();
license.SetLicense("");
ConversionConfig conversionConfig = new ConversionConfig { StoragePath = testPagesPath + “GroupDocStorage”, CachePath = testPagesPath + “GroupDocCache”, OutputPath = “GroupDocOutput” };
conversionConfig.UseCache = false;
ConversionHandler conversionHandler = new ConversionHandler(conversionConfig);
var convertedDocxStream = conversionHandler.Convert(streamPDF, new WordsSaveOptions { ConvertFileType = WordsSaveOptions.WordsFileType.Docx });
using (MemoryStream ms = new MemoryStream())
{
convertedDocxStream.CopyTo(ms);
bytWordX = ms.ToArray();
}
}
catch (Exception e)
{
Hashtable ht = new Hashtable(2);
ht.Add(“bytePDF”, bytePDF);
MethodInfo objMethod = (MethodInfo)MethodBase.GetCurrentMethod();
GlobalExceptionHandler.customExceptionHandler(e, objMethod, ht, ErrorSeverityType.Normal);
}
return bytWordX;
}
Regards,
Mohit Datta