Class Page

Class Page

Namespace: Aspose.Note Assembly: Aspose.Note.dll (25.4.0)

Represents a page.

public sealed class Page : CompositeNode<IPageChildNode>, INode, ICompositeNode<IPageChildNode>, ICompositeNode, IEnumerable<IPageChildNode>, IEnumerable

Inheritance

object Node CompositeNodeBase CompositeNode Page

Implements

INode , ICompositeNode , ICompositeNode , IEnumerable , IEnumerable

Inherited Members

CompositeNode<IPageChildNode>.GetEnumerator()
CompositeNode<IPageChildNode>.InsertChild<T1>(int, T1)
CompositeNode<IPageChildNode>.InsertChildrenRange(int, IEnumerable<IPageChildNode>)
CompositeNode<IPageChildNode>.InsertChildrenRange(int, params IPageChildNode[])
CompositeNode<IPageChildNode>.AppendChildFirst<T1>(T1)
CompositeNode<IPageChildNode>.AppendChildLast<T1>(T1)
CompositeNode<IPageChildNode>.RemoveChild<T1>(T1)
CompositeNode<IPageChildNode>.Accept(DocumentVisitor)
CompositeNode<IPageChildNode>.GetChildNodes(NodeType)
CompositeNode<IPageChildNode>.GetChildNodes<T1>()
CompositeNode<IPageChildNode>.IsComposite
CompositeNode<IPageChildNode>.FirstChild
CompositeNode<IPageChildNode>.LastChild
CompositeNodeBase.GetChildNodes(NodeType)
CompositeNodeBase.GetChildNodes<T1>()
Node.Accept(DocumentVisitor)
Node.Document
Node.IsComposite
Node.NodeType
Node.ParentNode
Node.PreviousSibling
Node.NextSibling
object.GetType()
object.ToString()
object.Equals(object?)
object.Equals(object?, object?)
object.ReferenceEquals(object?, object?)
object.GetHashCode()

Examples

Shows how to set a page’s background color.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();

// Load OneNote document and get first child
Document document = new Document(Path.Combine(dataDir, "Aspose.one"));

foreach (var page in document)
{
    page.BackgroundColor = Color.BlueViolet;
}

document.Save(Path.Combine(dataDir, "SetPageBackgroundColor.one"));

Shows how to get meta information about a page.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();

// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));

foreach (Page page in oneFile)
{
    Console.WriteLine("LastModifiedTime: {0}", page.LastModifiedTime);
    Console.WriteLine("CreationTime: {0}", page.CreationTime);
    Console.WriteLine("Title: {0}", page.Title);
    Console.WriteLine("Level: {0}", page.Level);
    Console.WriteLine("Author: {0}", page.Author);
    Console.WriteLine();
}

Shows how to set a title for a page.

string dataDir = RunExamples.GetDataDir_Text();
string outputPath = Path.Combine(dataDir, "CreateTitleMsStyle_out.one");

var doc = new Document();
var page = new Page(doc);

page.Title = new Title(doc)
{
    TitleText = new RichText(doc)
    {
        Text = "Title text.",
        ParagraphStyle = ParagraphStyle.Default
    },
    TitleDate = new RichText(doc)
    {
        Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
        ParagraphStyle = ParagraphStyle.Default
    },
    TitleTime = new RichText(doc)
    {
        Text = "12:34",
        ParagraphStyle = ParagraphStyle.Default
    }
};

doc.AppendChildLast(page);

doc.Save(outputPath);

Shows how to get a page’s history.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();

// Load OneNote document
Document document = new Document(Path.Combine(dataDir, "Aspose.one"), new LoadOptions { LoadHistory = true });

// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
    Console.WriteLine("LastModifiedTime: {0}", pageRevision.LastModifiedTime);
    Console.WriteLine("CreationTime: {0}", pageRevision.CreationTime);
    Console.WriteLine("Title: {0}", pageRevision.Title);
    Console.WriteLine("Level: {0}", pageRevision.Level);
    Console.WriteLine("Author: {0}", pageRevision.Author);
    Console.WriteLine();
}

Shows how to edit a page’s meta information.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();

// Load OneNote document and get first child
Document document = new Document(Path.Combine(dataDir, "Aspose.one"));
Page page = document.FirstChild;

// Reading Content Revision Summary for this page
var pageRevisionInfo = page.PageContentRevisionSummary;

Console.WriteLine($"Author:\t{pageRevisionInfo.AuthorMostRecent}\nModified:\t{pageRevisionInfo.LastModifiedTime:dd.MM.yyyy HH:mm:ss}");

// Update Page Revision Summary for this page
pageRevisionInfo.AuthorMostRecent = "New Author";
pageRevisionInfo.LastModifiedTime = DateTime.Now;

document.Save(Path.Combine(dataDir, "WorkingWithPageRevisions_out.one"));

Shows how to pass through all pages and make a replacement in the text.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();

var replacements = new Dictionary<string, string>
{
    { "Some task here", "New Text Here" }
};

// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));

// Get all RichText nodes
var textNodes = oneFile.GetChildNodes<RichText>();

foreach (var richText in textNodes)
{
    foreach (var kvp in replacements)
    {
        richText.Replace(kvp.Key, kvp.Value);
    }
}

string outputPdf = Path.Combine(dataDir, "ReplaceTextOnAllPages_out.pdf");

// Save to any supported file format
oneFile.Save(outputPdf, SaveFormat.Pdf);

Shows how to pass through a page’s text and make a replacement.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();

var replacements = new Dictionary<string, string>
{
    { "voice over", "voice over new text" }
};

// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));

// Get the first page
var pageNodes = oneFile.GetChildNodes<Page>();

// Get all RichText nodes on that page
var textNodes = pageNodes[0].GetChildNodes<RichText>();

foreach (var richText in textNodes)
{
    foreach (var kvp in replacements)
    {
        richText.Replace(kvp.Key, kvp.Value);
    }
}

string outputPartPdf = Path.Combine(dataDir, "ReplaceTextOnParticularPage_out.pdf");
oneFile.Save(outputPartPdf, SaveFormat.Pdf);
 English