This doesn't work.. Docx -> html
- Code: Select all
using (MemoryStream sm1 = new MemoryStream())
{
document.SaveToStream(sm1, FileFormat.Html);
}
This does work...... Docx -> PDF
- Code: Select all
using (MemoryStream sm1 = new MemoryStream())
{
document.SaveToStream(sm1, FileFormat.PDF);
}
The error output is as follows...... System.NullReferenceException
One of the doc files is attached so you may replicate the issue.
{System.NullReferenceException: Object reference not set to an instance of an object.
at sprẎ.ᜁ(Image A_0)
at sprẎ.ᜀ(DocPicture A_0)
at sprẎ.ᜄ(Paragraph A_0)
at sprẎ.ᜀ(BodyRegion A_0)
at sprẎ.ᜀ(Section A_0)
at sprẎ.ᜁ(Document A_0)
at sprẎ.ᜁ(Document A_0, String A_1)
at sprẎ.ᜀ(Document A_0, Stream A_1)
at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
at PaymentManager.Service.LetterService.CreateLetterText(LetterType type, ContactLetterMergeModel contact) in c:\Users\johnm_000\Desktop\SaasSite\PaymentManager\iCollect Web App\PaymentManager\Service\LetterService.cs:line 219
at PaymentManager.Controllers.FurtherActionController.SendThankYou(Nullable`1 debtId) in c:\Users\johnm_000\Desktop\SaasSite\PaymentManager\iCollect Web App\PaymentManager\Controllers\FurtherActionController.cs:line 207
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()}