1

Iam trying to pass in a MemoryStream(not a Filestream).

This is what I did:

        XWPFDocument w2 = new XWPFDocument(memoryStream);

This is what I get:

EOF in header

Updated my post:

        var m_a = new MemoryStream(File.ReadAllBytes(path_docx));

        // this works:
        //byte[] tempDatei = m_a.ToArray();
        //XWPFDocument m_w1 = new XWPFDocument(new MemoryStream(tempDatei)); 

        XWPFDocument m_w1 = new XWPFDocument(m_a);
        //  ... do something with the document
        m_w1.Write(m_a);

        // Actually, I want to use the same MemoryStream
        XWPFDocument m_w2 = new XWPFDocument(m_a);
        m_a.Position = 0;
        //  ... do something with the document
        m_w2.Write(m_a);

        // Dispose later
        if (m_a != null)
        {
            m_a.Close();
            m_a.Dispose();
        }

The main goal is to use the same MemoryStream, dispose later

  • 2
    Is the memory stream empty? It seems to be attempting to read pdf info and if the stream is empty it cannot even read the header to determine if it is a pdf. – juharr Apr 28 '20 at 13:10
  • 2
    Can you show us how you are creating/populating the MemoryStream? A [mre] would help us help you. – Brian Rogers Apr 29 '20 at 03:10

0 Answers0