Hi Eric,
Quick question how to use OpenXmlRegex.Replace to replace placeholder with content that has text and carriage return?
The placeholderValue can paragraph
public void WordReplacePlaceHolders(string sourceFilePath, Dictionary<string, string> placeholders, string outputFilePath)
{
File.Copy(sourceFilePath, outputFilePath, true);
using (var doc = WordprocessingDocument.Open(outputFilePath, true))
{
foreach (var part in doc.ContentParts())
{
var xdoc = part.GetXDocument();
var content = xdoc.Descendants(W.p);
foreach (string placeholder in placeholders.Keys)
{
var regex = new Regex(placeholder, RegexOptions.IgnoreCase);
var placeholderValue = placeholders[placeholder];
OpenXmlRegex.Replace(content, regex, placeholderValue, null);
}
part.PutXDocument();
}
doc.Save();
}
}