|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Text;
|
|
|
using Novacode;
|
|
|
|
|
|
using System.Drawing;
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
using Novacode;
|
|
|
|
|
|
|
|
|
namespace ConsoleApplication3
|
|
|
namespace ConsoleApplication3
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
{
|
|
|
{
|
|
|
static void Main(string[] args)
|
|
|
static void Main(string[] args)
|
|
|
{
|
|
|
{
|
|
|
// Create a new document.
|
|
|
|
|
|
using (DocX document = DocX.Create(@"Test.docx"))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Add Headers to the document.
|
|
|
|
|
|
document.AddHeaders();
|
|
|
|
|
|
|
|
|
|
|
|
// Get the default Header.
|
|
|
|
|
|
Header header = document.Headers.odd;
|
|
|
|
|
|
|
|
|
String filename = @"C:\Users\cathal\Downloads\ExternalAssessmentT.docx";
|
|
|
|
|
|
|
|
|
// Insert a Paragraph into the Header.
|
|
|
|
|
|
Paragraph p0 = header.InsertParagraph();
|
|
|
|
|
|
|
|
|
|
|
|
// Append place holders for PageNumber and PageCount into the Header.
|
|
|
|
|
|
// Word will replace these with the correct value foreach Page.
|
|
|
|
|
|
p0.Append("Page (");
|
|
|
|
|
|
p0.AppendPageNumber(PageNumberFormat.normal);
|
|
|
|
|
|
p0.Append(" of ");
|
|
|
|
|
|
p0.AppendPageCount(PageNumberFormat.normal);
|
|
|
|
|
|
p0.Append(")");
|
|
|
|
|
|
|
|
|
|
|
|
p0.ReplaceText("Page (", "Monster <");
|
|
|
|
|
|
p0.ReplaceText(")", ">");
|
|
|
|
|
|
|
|
|
using (DocX doc = DocX.Load(filename))
|
|
|
|
|
|
{
|
|
|
|
|
|
doc.ReplaceText("{Company Name}", "Penn Inc.", false);
|
|
|
|
|
|
doc.ReplaceText("{Primary Contact}", "John Smith", false);
|
|
|
|
|
|
|
|
|
// Save the document.
|
|
|
|
|
|
document.Save();
|
|
|
|
|
|
|
|
|
doc.AddCoreProperty("dc:subject", "CLE-OP55555");
|
|
|
|
|
|
|
|
|
|
|
|
doc.SaveAs(@"C:\Users\cathal\Downloads\ExternalAssessmentT2.docx");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|