Click or drag to resize

DocumentPage Class

Represents a document page.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentDocumentPage

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 5.0.10.23
Syntax
public sealed class DocumentPage

The DocumentPage type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleContent
Represents an area in document bounded by two ContentPositions.
Public propertyElementsOnPage
Represents a IEnumerable with Elements for one page. If Element conteins on two or more page then every page include this element.
Public propertyHeight
Gets the page height in points.
Public propertyCode examplePageSetup
Represents the page setup properties: paper type, orientation, margins and so forth.
Public propertyWidth
Gets the page width in Points.
Top
Methods
  NameDescription
Public methodGetContent
Returns the content of the page as FrameworkElement object.
Public methodCode exampleRasterize(Int32)
Rasterizes the document page to Bitmap.
Public methodCode exampleRasterize(Int32, Color)
Rasterizes the document page to Bitmap.
Public methodCode exampleSave(String)
Saves the document page to a file with the specified path. Path must include file extension.
Public methodCode exampleSave(Stream, SaveOptions)
Saves the document page in the specified stream.
Public methodCode exampleSave(String, SaveOptions)
Saves the document page to a file with the specified path.
Top
Examples
Loads a document and split it by separate pages. Saves the each page into PDF format in C#
using System.IO;
using SautinSoft.Document;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            SplitDocumentByPages();
        }
        /// <summary>
        /// Loads a document and split it by separate pages. Saves the each page into PDF format.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/split-docx-document-by-pages-in-pdf-format-net-csharp-vb.php
        /// </remarks>
        static void SplitDocumentByPages()
        {
            string filePath = @"..\..\example.docx";
            DocumentCore dc = DocumentCore.Load(filePath);
            string folderPath = Path.GetFullPath(@"Result-files");
            DocumentPaginator dp =  dc.GetPaginator();
            for (int i = 0; i < dp.Pages.Count; i++)
            {
                DocumentPage page = dp.Pages[i];
                Directory.CreateDirectory(folderPath);

                // Save the each page to PDF format.
                page.Save(folderPath + @"\Page - " + i.ToString() + ".pdf", SaveOptions.PdfDefault);
            }
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(folderPath) { UseShellExecute = true });
        }
    }
}
Loads a document and split it by separate pages. Saves the each page into PDF format in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        SplitDocumentByPages()
    End Sub

    ''' <summary>
    ''' Loads a document and split it by separate pages. Saves the each page into PDF format.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/split-docx-document-by-pages-in-pdf-format-net-csharp-vb.php
    ''' </remarks>
    Sub SplitDocumentByPages()
        Dim filePath As String = "..\example.docx"
        Dim dc As DocumentCore = DocumentCore.Load(filePath)
        Dim folderPath As String = Path.GetFullPath("Result-files")
        Dim dp As DocumentPaginator = dc.GetPaginator()
        For i As Integer = 0 To dp.Pages.Count - 1
            Dim page As DocumentPage = dp.Pages(i)
            Directory.CreateDirectory(folderPath)

            ' Save the each page to PDF format.
            page.Save(folderPath & "\Page - " & i.ToString() & ".pdf", SaveOptions.PdfDefault)
        Next i
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(folderPath) With {.UseShellExecute = True})
    End Sub
End Module
See Also