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.

Fri Jun 15, 2012 3:23 pm

Hi,

I am using the Spire.Doc component to insert images into word documents. When the spire.doc component comes across a .doc word document, it inserts the image into it without any problems. However, when it comes across a .docx word document, it does not insert an image into it. I've debugged it many times to see if the .docx word document was open from spire.doc component, and it shows that it has. So, I am at a lost. No exception is being thrown from the spire.doc component. So, why then is it, that the image is not being inserted into the .docx word document but, is being inserted into the .doc word document? I need your help on this. Thank you.

p.s. - I am currently using the Spire.doc 4.2.9.4 version.

dawasoft
 
Posts: 3
Joined: Fri Mar 30, 2012 7:48 pm

Mon Jun 18, 2012 2:43 am

Hi dawasoft,

Thanks for using Spire.Doc. As the issue you reported, we have created a research on it, but we need some more time to fix it. I can not provide you any reliable estimate regarding it's complexity. However, you will be surely informed once we fix it. Thanks for your understanding and cooperation.

Have a nice day.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nancy
e-iceblue support
Nancy
e-iceblue support team
contact: nancy.wang@e-iceblue.com
User avatar

nancy
 
Posts: 51
Joined: Wed May 30, 2012 2:02 am

Mon Jun 18, 2012 4:03 am

Hi dawasoft,

You need to specify the format of file using the property "FileFormat.Docx " or "FileFormat.Docx2010". I don't know if you have setted it. You can try the following code:
// new document
Document doc1 = new Document();
doc1.LoadFromFile(@"E:\myProject\resources\myfile.docx"); // replace into your own file location.

//get the paragraph of the first section in docx file
Section section = doc1.Sections[0];
Paragraph paragraph = section.Paragraphs[0];

// add picture
paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
paragraph.AppendPicture(Image.FromFile(@"E:\myProject\resources\myfile.jpg"));

// save and launch
doc1.SaveToFile(@"..\..\530.docx",FileFormat.Docx); // replace into your own location of saving file.
System.Diagnostics.Process.Start(@"..\..\530.docx"); // replace the location.

If you still can't solve the problem, please contact me!
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nancy,
e-iceblue support
Nancy
e-iceblue support team
contact: nancy.wang@e-iceblue.com
User avatar

nancy
 
Posts: 51
Joined: Wed May 30, 2012 2:02 am

Mon Jun 18, 2012 3:28 pm

Hi Nancy,

Thank you for your response. I have tried implementing it your way. It still did not work. I made sure that when saving the file that the FileFormat was set to FileFormat.Docx. What you sent me is basically the same way I have it set up in my code. I am using Spire.doc version 4.2.9.4 and the word version I am using is 2007. Could it be that I need to download a newer version of Spire.doc? or Spire.doc does not insert images into .docx documents?



Cordially Yours,
David Watson.

dawasoft
 
Posts: 3
Joined: Fri Mar 30, 2012 7:48 pm

Tue Jun 19, 2012 1:46 am

Hi David Waston,

I am testing your problem, and I will give you a reply as soon as possible. Thank you for your cooperation and understanding.

Have a nice day!
----------------------------------------------------------------------------------------------------------------------------------------------------
Nancy
e-iceblue support
Nancy
e-iceblue support team
contact: nancy.wang@e-iceblue.com
User avatar

nancy
 
Posts: 51
Joined: Wed May 30, 2012 2:02 am

Tue Jun 19, 2012 2:46 am

Hi David Waston,

I still can't reproduce your problem, can you send me the file that you have loaded? Our email address is support@e-iceblue.com
Thank you for your cooperation and understanding.
-------------------------------------------------------------------------------------------------------------------------------------------------------
Nancy
e-iceblue support
Nancy
e-iceblue support team
contact: nancy.wang@e-iceblue.com
User avatar

nancy
 
Posts: 51
Joined: Wed May 30, 2012 2:02 am

Wed Jul 11, 2012 5:30 pm

Thank you Nancy. Your suggestion to download the spire.doc v4.3.6 version allowed for my application to insert images into both .doc and .docx word documents successfully.
Thank you again Nancy.


Cordially Yours,
David Watson.

dawasoft
 
Posts: 3
Joined: Fri Mar 30, 2012 7:48 pm

Thu Jul 12, 2012 2:07 am

Hi dawasoft,

You're welcome! ^_^
Nancy
e-iceblue support team
contact: nancy.wang@e-iceblue.com
User avatar

nancy
 
Posts: 51
Joined: Wed May 30, 2012 2:02 am

Return to Spire.Doc