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 Sep 17, 2020 3:25 pm

Hello,

I am using FreeSpire.Doc to manipulate an image in a Word document generated by a different extension.
Once I'm done with the file, I use the Gembox.Document extension to try and print the document. The printer prints out a Test page instead of the document. It seems like the document is still being reserved by Freespire.Doc even after I try to Close() and Dispose() of the file.

To confirm the problem is indeed in Freespire.Doc, I installed the Trial version of Spire.Doc to see if the same bug happens (using the exact same code) and I do not get that error. The document does print part of the image, before the "Trial version" message appears to cut off half the document. I also tried printing the Word document without doing the manipulations I'm doing with Freespire.Doc, and the file also prints just fine...

I believe this bug was fixed in a Hotfix in the standard Spire.Doc extension, referring to this ticket:

..../word-can-t-open-file-after-spiredoc-process-t7937.html

Here's a sample of my code:

Code: Select all
//Relevant Freespire.Doc code
                    Spire.Doc.Document spireDoc = new Spire.Doc.Document(m_strFilePath + ".docx");
                   
                    Spire.Doc.Documents.Paragraph paragraph = spireDoc.Sections[0].Paragraphs[0];
                    DocPicture picture = paragraph.AppendPicture(System.Drawing.Image.FromFile(m_strFilePath));
                    picture.Rotation = 270;
                    picture.TextWrappingStyle = TextWrappingStyle.Through;
                    picture.TextWrappingType = TextWrappingType.Both;
                    picture.HorizontalAlignment = ShapeHorizontalAlignment.Right;
                    picture.VerticalAlignment = ShapeVerticalAlignment.Bottom;

                    spireDoc.SaveToFile(m_strFilePath + ".docx", FileFormat.Docx);
                    spireDoc.Close();
                    spireDoc.Dispose();

//Gembox.Document to print it
            m_strFilePath += ".docx";
            GemBox.Document.DocumentModel document = GemBox.Document.DocumentModel.Load(m_strFilePath);
            string printerName = "GeniePrinter1";

            document.Print(printerName);


Is this a known bug, or am I doing something wrong?
Thank you for your assistance.

gilgameshgg
 
Posts: 1
Joined: Fri Aug 28, 2020 6:19 pm

Fri Sep 18, 2020 9:29 am

Hello,

Thanks for your inquiry.
According to your description, the issue that the document is still being reserved by our product does not exist in our commercial version, right? Please note that we just upgrade our free version irregularly, thus, I recommend you use our commercial version.
Meanwhile, our Spire.Doc also supports printing Word documents, you can use our Spire.Doc to print directly.

Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Return to Spire.Doc