Hey Eric,
I’m having an issue merging complex documents with headers at specific locations.
Here’s an example:
var letterhead = @"C:\Users\dheale\Desktop\Word Docs\TESTING\StandardLetterhead.DOCX";
var blackrule = @"C:\Users\dheale\Desktop\Word Docs\TESTING\NJBlackrule.DOCX";
var asb = @"C:\Users\dheale\Desktop\Word Docs\TESTING\asb.DOCX";
var outDoc = @"C:\Users\dheale\Desktop\Word Docs\TESTING\out.DOCX";
var sources = new List<Source>
{
new Source(new WmlDocument(asb), 0, 80, false),
new Source(new WmlDocument(letterhead), true),
new Source(new WmlDocument(asb), 80,120, false),
new Source(new WmlDocument(blackrule), true),
new Source(new WmlDocument(asb), 120, false),
new Source(new WmlDocument(letterhead), true)
};
var doc = DocumentBuilder.BuildDocument(sources);
My issue is trying to figure out what the paragraph index is. The original document has tags to identify where the template should be placed.
Currently to get the ID I’m doing the following:
var ParagraphIndex = wordDoc.MainDocumentPart.Document.Body.ChildElements.Where(w => w.XmlQualifiedName.Name == "p").ToList().FindIndex(f => f.InnerXml.Contains(templateTag));
However, the longer the document, the more off this index is.
Is there a better and more accurate way of getting the indexes of the paragraphs?
Thanks