public void ByPageRange() { //ExStart:SplitDocumentByPageRange Document doc = new Document(MyDir + "Big document.docx"); // Split nodes in the document into separate pages. DocumentPageSplitter splitter = new DocumentPageSplitter(doc); // Get part of the document. Document pageDoc = splitter.GetDocumentOfPageRange(3, 6); pageDoc.Save(ArtifactsDir + "SplitDocument.ByPageRange.docx"); //ExEnd:SplitDocumentByPageRange }
public void PageByPage() { //ExStart:SplitDocumentPageByPage Document doc = new Document(MyDir + "Big document.docx"); // Split nodes in the document into separate pages. DocumentPageSplitter splitter = new DocumentPageSplitter(doc); // Save each page as a separate document. for (int page = 1; page <= doc.PageCount; page++) { Document pageDoc = splitter.GetDocumentOfPage(page); pageDoc.Save(ArtifactsDir + $"SplitDocument.PageByPage_{page}.docx"); } //ExEnd:SplitDocumentPageByPage MergeDocuments(); }
public void SplitDocumentToPages(string docName) { string fileName = Path.GetFileNameWithoutExtension(docName); string extensionName = Path.GetExtension(docName); Console.WriteLine("Processing document: " + fileName + extensionName); Document doc = new Document(docName); // Split nodes in the document into separate pages. DocumentPageSplitter splitter = new DocumentPageSplitter(doc); // Save each page to the disk as a separate document. for (int page = 1; page <= doc.PageCount; page++) { Document pageDoc = splitter.GetDocumentOfPage(page); pageDoc.Save(Path.Combine(ArtifactsDir, $"{fileName} - page{page} Out{extensionName}")); } }