Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Dec 06, 2012 9:03 pm

I have a document with 40 items to be merged, all are pretty simple fields. I am opening the template from a stream and have the following problems when executing the following code:

using (memStr = new MemoryStream())
{
document.SaveToStream(memStr, FileFormat.Doc);
}

1) For PDF I get a stack overflow exception
2) For docx every merge field gets replaced with the value twice.
3) For doc everything looks fine though Word throws errors opening the doc.

I have the latest version of the software and the hot fix. Are these known issues and is there any fix date?

ps. I can't post my template here due to it's sensitive nature but could mail it if need be.

Thanks

keithn
 
Posts: 2
Joined: Thu Dec 06, 2012 8:58 pm

Fri Dec 07, 2012 3:00 am

Hello keithn,

Thanks for your inquiry.
Could you please send your template document to support@e-iceblue.com? Also could you please provide us your code which can directly help us to reproduce all your problems? So that we can work out solutions for you soon. Thank you!

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Fri Dec 07, 2012 2:16 pm

Downloading your latest hotfix fixed the issues with PDF getting a stack overflow.

I was able to generate the error with each item appearing twice using the Fax template sample that you include when using SaveToStream.

keithn
 
Posts: 2
Joined: Thu Dec 06, 2012 8:58 pm

Mon Dec 10, 2012 3:46 am

Hi keithn,

Thanks for your feedback.
We are sorry for the delay response for weekends here.
We are happy to hear that our latest hotfix fixed #1.
For #2 and #3, we use Fax template sample to do some tests. But we don't reproduce #2 when generate a .docx file. Could you please provide us your code? So that we can quickly reproduce your problem, and work out a solution for you soon. We get a security alert error when open the generated .doc file. Could you please tell us what was the error you encountered when opened the generated .doc file? Is also it the security alert error? Thank you!

Best regards,
Amy
E-iceblue support
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Tue Dec 18, 2012 8:30 am

Hello keithn,

Did you still have the problems about #2 and #3? If you did, please tell us. For #2, could you please provide us your code? So that we can reproduce your problem. For #3, could you please tell us the error you encountered? Thank you!

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 17, 2013 10:20 am

Hello keithn,

We released a new hotfix of spire.doc. Please use Spire.Doc Pack (Hot Fix) Version:4.6.9 (the download link is http://www.e-iceblue.com/Download/download-word-for-net-now/spiredoc-pack-hot-fix469.html?Itemid=0)to test #2 issue and #3 issue.
If you still have #2 issue and #3 issue, please tell us. Thank you!

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Sat Jan 19, 2013 9:39 am

Hello. I recently purchased and upgraded to Spire.Doc 4.6 (+ 4.6.9 hot fix) for Developer Pro Edition. I have a doc/docx stored as a varbinary(max) in an SQL2005/SQL2008 database table column. I can get the data from the column and load to a Spire.Doc.Document in some cases but in others I receive a "A disk error occurred during a write operation. (Exception from HRESULT:0X8003001D (STG_E_WRITEFAULT)) error. I have attached code I am using. It seems that small doc/docx files work correctly but not larger ones (>99KB). Please advise asap. Here is code being used.

If thisDocument._FileContent IsNot Nothing Then
Dim tempFileNamePDF As String
Dim spireFormat As FileFormat
If thisDocument._DiskFileName.Contains(".docx") Then
tempFileNamePDF = thisDocument._DiskFileName.Replace(".docx", ".pdf")
spireFormat = FileFormat.Docx
Else
tempFileNamePDF = thisDocument._DiskFileName.Replace(".doc", ".pdf")
spireFormat = FileFormat.Doc
End If

Dim ms As New MemoryStream()
Dim bw As New BinaryWriter(ms)
bw.Write(thisDocument._FileContent)
bw.Flush()

'Load the temp file into a Word Document object
Dim doc As Document = New Document(ms, spireFormat) <---- Exception occurs here !!!

'Create a new memorystream to hold the pdf and populate it (convert word to pdf here)
Dim pdfMS As New MemoryStream()
doc.SaveToStream(pdfMS, FileFormat.PDF)
doc.Close()

'Write pdf memory stream to byte array for delivery in the response
Dim pdfBytes As Byte()
pdfBytes = pdfMS.ToArray()
pdfMS.Close()

'Clear the content of the response
Response.ClearContent()
Response.ClearHeaders()
'Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
'Response.AddHeader("Content-Disposition", "attachment; filename=" + tempFileNamePDF.Replace(userNameMashUp, ""))
Response.AddHeader("Content-Disposition", "attachment; filename=" + tempFileNamePDF)
'Add the file size into the response header
Response.AddHeader("Content-Length", pdfBytes.Length.ToString())
'Set the ContentType as saved in database
Response.ContentType = "application/pdf"
'Write the file into the response
Response.BinaryWrite(pdfBytes)
'End the response
Response.End()
Else
Session("ErrorMessage") = "Error from DocumentList: The document " & fileName & " could not be retrieved from the database."
Throw New Exception("Error from DocumentList: The document " & fileName & " could not be retrieved from the database.")
End If

Roundhouse560
 
Posts: 2
Joined: Mon Jan 14, 2013 11:00 pm

Mon Jan 21, 2013 2:20 am

Hi Gary,

We are sorry for the delay response for the weekends here.
You need to reset the position of the object MemeryStream before using, please try:
Code: Select all
bw.Write(thisDocument._FileContent)
bw.Flush()

'reset the position
ms.Position = 0

'Load the temp file into a Word Document object
Dim doc As Document = New Document(ms, spireFormat)    <--- Exception occurs here…………………………………………...

If you still has this question, please tell us.

Thanks and Regards,
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Mon Jan 21, 2013 1:35 pm

The suggested fix worked like a charm...

You need to reset the position of the object MemeryStream, please try:
bw.Write(thisDocument._FileContent)
bw.Flush()

'reset the position
ms.Position = 0

'Load the temp file into a Word Document object
Dim doc As Document = New Document(ms, spireFormat) <--- Exception occurs here…………………………………………...

Roundhouse560
 
Posts: 2
Joined: Mon Jan 14, 2013 11:00 pm

Return to Spire.Doc