Aspose.Words.Examples.CSharp.Loading_Saving.DocumentPageSplitter.GetDocumentOfPage C# (CSharp) Метод

GetDocumentOfPage() публичный Метод

Gets the document of a page.
public GetDocumentOfPage ( int pageIndex ) : Document
pageIndex int 1-based index of a page.
Результат Document
        public Document GetDocumentOfPage(int pageIndex)
        {
            return GetDocumentOfPageRange(pageIndex, pageIndex);
        }

Usage Example

        public static void SplitDocumentToPages(string docName)
        {
           
            string folderName = Path.GetDirectoryName(docName);
            string fileName = Path.GetFileNameWithoutExtension(docName);
            string extensionName = Path.GetExtension(docName);
            string outFolder = Path.Combine(folderName, "_out");

            Console.WriteLine("Processing document: " + fileName + extensionName);

            Document doc = new Document(docName);

            // Create and attach collector to the document before page layout is built.
            LayoutCollector layoutCollector = new LayoutCollector(doc);

            // This will build layout model and collect necessary information.
            doc.UpdatePageLayout();

            // Split nodes in the document into separate pages.
            DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);

            // 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(outFolder, string.Format("{0} - page{1} Out{2}", fileName, page, extensionName)));
            }

            // Detach the collector from the document.
            layoutCollector.Document = null;
            
        }
All Usage Examples Of Aspose.Words.Examples.CSharp.Loading_Saving.DocumentPageSplitter::GetDocumentOfPage