Dec 30, 2011 at 5:35 PM
Edited Dec 30, 2011 at 5:36 PM
I have had a look at your request "allow text to be placed on-top of images". Its a little bit messy but I am going to give it a try tomorrow.
Here is why it is messy.
Normally everything in a document is inline. This means that you never have to provide co-ordinates for anything and word decides how everything should be placed. When you decide to overlay things such as text and
pictures, one of these things "the picture" has to be inserted into the document as a floating element i.e. not inline. This means it needs to have an anchor and relative horizontal and vertical co-cordinates.
This means that the code might end up writing code like this.
// Create a document.
using (DocX document = DocX.Create(@"C:\Users\cathal\Desktop\Test.docx"))
// Add an Image to the document.
Novacode.Image img = document.AddImage(@"C:\Users\cathal\Desktop\Test.jpg");
// Create a picture from the Image.
Picture pic = img.CreatePicture();
pic.TextWrapping = TextWrapping.BehindText;
pic.AbsoluteHorizontal = new AbsoluteHorizontal(1.72, TextWrappingHorizontal.Column);
pic.AbsoluteVertical = new AbsoluteVertical(-0.8, TextWrappingVertical.Paragraph);
// Add Footers to the document.
// Get the default footer.
Footer footer = document.Footers.odd;
// Insert a Paragraph with some large, red text and our Picture;
The code in bold is quite ugly. I need to think longer and harder how to make this better.
At the moment I am not happy with this solution.