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 Feb 13, 2020 8:08 pm

Word Document corrupted attachment after editing.
Adjunct images code for OPENING, EDITING, AND SAVING.
Also include corrupted document.


I appreciate your help for issue.

cotoql
 
Posts: 14
Joined: Tue Oct 28, 2014 9:41 pm

Fri Feb 14, 2020 2:55 am

Hello,

Thanks for your inquiry.
The attached file "C-0004.doc" should be your input file, rather than the corrupted output file as you said, right? Because I didn't encounter any problem when opening it using Microsoft Word.

I tested your Word file with the latest Spire.Doc Pack(hot fix) Version:8.2.4 but the output file has no issues. Below is the code I used, and I also attached my output file for your reference. If you were using an old version, please try again with the latest version.
Code: Select all
        'Agrega el usuario revisor o aprobador y la fecha en el pie de página del documento
        Dim documentoCedula As New Document()
        documentoCedula.LoadFromFile("C-0004.doc", FileFormat.Doc)
        Dim seccionDelDocumento = documentoCedula.Sections(0)
        Dim piePagina = seccionDelDocumento.HeadersFooters.Footer
        Dim cantidadDeParrafos = seccionDelDocumento.HeadersFooters.Footer.Paragraphs.Count
        'Borra el revisor y aprobador del pie de página del documento
        If cantidadDeParrafos > 2 Then
            For index As Integer = cantidadDeParrafos - 1 To 2 Step -1
                seccionDelDocumento.HeadersFooters.Footer.Paragraphs.RemoveAt(index)
            Next
        End If
        Dim parrafo As Paragraph = piePagina.AddParagraph()
        Dim texto As TextRange = parrafo.AppendText("descripcionDeLaAccion")
        texto.CharacterFormat.FontName = "Calibri"
        texto.CharacterFormat.FontSize = 12
        parrafo.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left
        'Convierte el documento en arreglo de bytes
        Dim ms As MemoryStream = New MemoryStream()
        documentoCedula.SaveToStream(ms, FileFormat.Doc)
        Dim byteArray = ms.ToArray()
        Dim fileStream As FileStream = New FileStream("result.doc", FileMode.Create, FileAccess.ReadWrite)
        fileStream.Write(byteArray, 0, byteArray.Length)

If the issue still occurs, please provide your output file, your full code or a runnable project that could reproduce your issue for further investigation. You could send them to us via email (support@e-iceblue.com).

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Feb 19, 2020 10:03 am

Hello,

Greetings from E-iceblue!
How is your issue now? Could you please give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc