I have a word document which contains multiple pages and i want to copy some pages into new word document using OpenXml SDK. I did some web search and got below code which reads entire document and copies into new one
string documentURL = filelocation;
byte[] docAsArray = File.ReadAllBytes(documentURL);
using (MemoryStream stream = new MemoryStream())
{
stream.Write(docAsArray, 0, docAsArray.Length); // THIS performs doc copy
using (DocumentFormat.OpenXml.Packaging.WordprocessingDocument doc = DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(stream, true))
{
// perform content control substitution here, making sure to call .Save()
// on any documents Part's changed.
}
File.WriteAllBytes(outputSplitDocpath, stream.ToArray());
}
Now, in the above code how can i read just specific pages and copy into new one? Please help with suggestions. Thanks