Trying to Stream DocIO MailMerge to Client

I need to stream DocIO to the client as an attachment.  Was trying to use this method:

doc.Save("certificate.doc", FormatType.Doc, HttpContext.Current.Response, HttpContentDisposition.Attachment)

but it causes an aborted thread error because it's being called from within an update panel.

Now trying to use the other overload and save to memorystream instead and the good 'ol Response.BinaryWrite(bytes) a byte array method, but it's not working.  Below is what I have, but it isn't working, although I have used this method in the past with other products with no problems.  Any help would be greatly appreciated.

 

Dim Certificates As New System.IO.MemoryStream
doc.MailMerge.ExecuteNestedGroup(_ds, _commands)
doc.Save(Certificates, FormatType.Doc)
Dim bytes = New Byte(CType(Certificates.Length, Integer)) {}
Certificates.Read(bytes, 0, CInt(Certificates.Length))

      HttpContext.Current.Response.Buffer = True
      HttpContext.Current.Response.Charset = ""
      HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
      HttpContext.Current.Response.ContentType = "application/ms-word"
      HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filenname=certificates.doc")
      HttpContext.Current.Response.BinaryWrite(bytes)
      HttpContext.Current.Response.Flush()
      HttpContext.Current.Response.End()


1 Reply

RM Ramkumar M Syncfusion Team September 17, 2012 06:45 AM UTC

Hi Timothy,

Thank you for your interest in Syncfusion products.

We have created a sample to meet your requirement of stream document to client side while called from updated panel. Please find the sample from the below link and let us know if this helps you.

Sample Link:

http://www.syncfusion.com/downloads/Support/DirectTrac/98785/Sample54764073.zip

In this Sample:

We have used PostBackTrigger Class defines a control inside a UpdatePanel control as a postback control. For more information on PostBackTrigger Class please refer the below link

http://msdn.microsoft.com/en-us/library/system.web.ui.postbacktrigger.aspx

Please let us know if you have any questions.

 Regards

Ramkumar


Loader.
Up arrow icon