Class Page
Nom dels espais: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)
Representa una pàgina.
public sealed class Page : CompositeNode<ipagechildnode>, INode, ICompositeNode<ipagechildnode>, ICompositeNode, IEnumerable<ipagechildnode>, IEnumerable
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
INode
,
ICompositeNode
Membres heretats
CompositeNode
Examples
Mostra com configurar el color de fons de la pàgina.
// 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"));
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com configurar un títol per a una pàgina.
string dataDir = RunExamples.GetDataDir_Text();
string outputPath = 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);
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
Mostra com editar la meta informació de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document and get first child
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
// Reading Content Revision Summary for this page
var pageRevisionInfo = page.PageContentRevisionSummary;
Console.WriteLine(string.Format(
"Author:\t{0}\nModified:\t{1}",
pageRevisionInfo.AuthorMostRecent,
pageRevisionInfo.LastModifiedTime.ToString("dd.MM.yyyy HH:mm:ss")));
// Update Page Revision Summary for this page
pageRevisionInfo.AuthorMostRecent = "New Author";
pageRevisionInfo.LastModifiedTime = DateTime.Now;
document.Save(dataDir + "WorkingWithPageRevisions_out.one");
Mostra com passar per totes les pàgines i fer una substitució en el text.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string=""> replacements = new Dictionary<string, string="">();
replacements.Add("Some task here", "New Text Here");
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all RichText nodes
IList<richtext> textNodes = oneFile.GetChildNodes<richtext>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string=""> kvp in replacements)
{
// Replace text of a shape
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir = dataDir + "ReplaceTextOnAllPages_out.pdf";
// Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf);</string,></richtext></richtext></string,></string,>
Mostra com passar pel text de la pàgina i fer una substitució.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string=""> replacements = new Dictionary<string, string="">();
replacements.Add("voice over", "voice over new text");
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
IList<page> pageNodes = oneFile.GetChildNodes<page>();
// Get all RichText nodes
IList<richtext> textNodes = pageNodes[0].GetChildNodes<richtext>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string=""> kvp in replacements)
{
// Replace text of a shape
richText.Replace(kvp.Key, kvp.Value);
}
}
// Save to any supported file format
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);</string,></richtext></richtext></page></page></string,></string,>
Mostra com crear un document i salvar-lo en format html utilitzant les opcions de default.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
Mostra com afegir una nova imatge amb la etiqueta.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tags();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
// Insert image in the document node
outlineElem.AppendChildLast(image);
image.Tags.Add(NoteTag.CreateYellowStar());
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "AddImageNodeWithTag_out.one";
doc.Save(dataDir);
Mostra com comprovar si una pàgina és un conflicte (és a dir, té canvis que OneNote no podia fusionar automàticament).
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write(" {0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
i,
historyPage.PageContentRevisionSummary.AuthorMostRecent,
historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
// By default conflict pages are just skipped on saving.
// If mark it as non-conflict then it will be saved as usual one in the history.
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
Mostra com crear un document i guardar en format html la gamma de pàgines especificades.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
Mostra com crear un document amb una pàgina titulada.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Create an object of the Document class
Document doc = new Aspose.Note.Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Set page title properties
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
// Append Page node in the document
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "CreateDocWithPageTitle_out.one";
doc.Save(dataDir);
Mostra com guardar un document en diferents formats.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize the new Document
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
// Initialize the new Page
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
// Append page node
doc.AppendChildLast(page);
// Save OneNote document in different formats, set text font size and detect layout changes manually.
doc.Save(dataDir + "ConsequentExportOperations_out.html");
doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
textStyle.FontSize = 11;
doc.DetectLayoutChanges();
doc.Save(dataDir + "ConsequentExportOperations_out.bmp");
Mostra com introduir una nova llista amb el número xinès.
string dataDir = RunExamples.GetDataDir_Text();
// Initialize OneNote document
Aspose.Note.Document doc = new Aspose.Note.Document();
// Initialize OneNote page
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
// Apply text style settings
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Numbers in the same outline are automatically incremented.
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
//------------------------
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
//------------------------
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
//------------------------
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "InsertChineseNumberList_out.one";
doc.Save(dataDir);
Mostra com introduir una nova lis bulletada.
string dataDir = RunExamples.GetDataDir_Text();
// Create an object of the Document class
Aspose.Note.Document doc = new Aspose.Note.Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize TextStyle class object and set formatting properties
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Initialize OutlineElement class objects and apply bullets
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
// Initialize RichText class object and apply text style
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
// Add outline elements
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "ApplyBulletsOnText_out.one";
doc.Save(dataDir);
Mostra com introduir una nova llista amb el número.
string dataDir = RunExamples.GetDataDir_Text();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize TextStyle class object and set formatting properties
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Initialize OutlineElement class objects and apply numbering
// Numbers in the same outline are automatically incremented.
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
// Add outline elements
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "ApplyNumberingOnText_out.one";
doc.Save(dataDir);
Mostra com afegir una pàgina amb una subpàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object and set its level
Aspose.Note.Page page1 = new Aspose.Note.Page(doc) { Level = 1 };
// Initialize Page class object and set its level
Aspose.Note.Page page2 = new Aspose.Note.Page(doc) { Level = 2 };
// Initialize Page class object and set its level
Aspose.Note.Page page3 = new Aspose.Note.Page(doc) { Level = 1 };
/*---------- Adding nodes to first Page ----------*/
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "First page.", ParagraphStyle = textStyle };
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page1.AppendChildLast(outline);
/*---------- Adding nodes to second Page ----------*/
var outline2 = new Outline(doc);
var outlineElem2 = new OutlineElement(doc);
var textStyle2 = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
var text2 = new RichText(doc) { Text = "Second page.", ParagraphStyle = textStyle2 };
outlineElem2.AppendChildLast(text2);
outline2.AppendChildLast(outlineElem2);
page2.AppendChildLast(outline2);
/*---------- Adding nodes to third Page ----------*/
var outline3 = new Outline(doc);
var outlineElem3 = new OutlineElement(doc);
var textStyle3 = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
var text3 = new RichText(doc) { Text = "Third page.", ParagraphStyle = textStyle3 };
outlineElem3.AppendChildLast(text3);
outline3.AppendChildLast(outlineElem3);
page3.AppendChildLast(outline3);
/*---------- Add pages to the OneNote Document ----------*/
doc.AppendChildLast(page1);
doc.AppendChildLast(page2);
doc.AppendChildLast(page3);
// Save OneNote document
dataDir = dataDir + "CreateDocWithRootAndSubPages_out.one";
doc.Save(dataDir);
Constructors
Page()
Inicialitza una nova instància de la classe Aspose.Note.Page.
public Page()
Properties
Author
Obtenir o posar l’autor.
public string Author { get; set; }
Valor de la propietat
Examples
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
BackgroundColor
Obté o fixa el color de fons de la pàgina.
public Color BackgroundColor { get; set; }
Valor de la propietat
Examples
Mostra com configurar el color de fons de la pàgina.
// 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"));
Mostra com aplicar l’estil temàtic fosc a un document.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<richtext>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));</richtext>
CreationTime
Obtenir o establir el temps de creació.
public DateTime CreationTime { get; set; }
Valor de la propietat
Examples
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
IsConflictPage
Obté o estableix un valor que indiqui si aquesta pàgina és una pàgina de conflicte.
public bool IsConflictPage { get; set; }
Valor de la propietat
Examples
Mostra com comprovar si una pàgina és un conflicte (és a dir, té canvis que OneNote no podia fusionar automàticament).
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write(" {0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
i,
historyPage.PageContentRevisionSummary.AuthorMostRecent,
historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
// By default conflict pages are just skipped on saving.
// If mark it as non-conflict then it will be saved as usual one in the history.
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
Remarks
La pàgina de conflicte apareix quan dos usuaris intenten actualitzar el mateix contingut. En aquest cas, els canvis del primer usuari s’escriuen com a habitual. Però no es poden fusionar cançons d’un altre usuària.
En aquesta versió els conflictes es resolen en favor dels canvis del primer usuari. Per tant, si el document té pàgines de conflicte llavors es mostrarà en la història però s’esborrarà a l’estalvi.
Una mostra detallada de la manipulació per pàgina de conflicte es pot trobar en la documentació en línia.
LastModifiedTime
Obté o fixa l’últim temps modificat.
public DateTime LastModifiedTime { get; set; }
Valor de la propietat
Examples
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
Level
Obtenir o establir el nivell.
public byte Level { get; set; }
Valor de la propietat
Examples
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
Mostra com afegir una pàgina amb una subpàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object and set its level
Aspose.Note.Page page1 = new Aspose.Note.Page(doc) { Level = 1 };
// Initialize Page class object and set its level
Aspose.Note.Page page2 = new Aspose.Note.Page(doc) { Level = 2 };
// Initialize Page class object and set its level
Aspose.Note.Page page3 = new Aspose.Note.Page(doc) { Level = 1 };
/*---------- Adding nodes to first Page ----------*/
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "First page.", ParagraphStyle = textStyle };
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page1.AppendChildLast(outline);
/*---------- Adding nodes to second Page ----------*/
var outline2 = new Outline(doc);
var outlineElem2 = new OutlineElement(doc);
var textStyle2 = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
var text2 = new RichText(doc) { Text = "Second page.", ParagraphStyle = textStyle2 };
outlineElem2.AppendChildLast(text2);
outline2.AppendChildLast(outlineElem2);
page2.AppendChildLast(outline2);
/*---------- Adding nodes to third Page ----------*/
var outline3 = new Outline(doc);
var outlineElem3 = new OutlineElement(doc);
var textStyle3 = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
var text3 = new RichText(doc) { Text = "Third page.", ParagraphStyle = textStyle3 };
outlineElem3.AppendChildLast(text3);
outline3.AppendChildLast(outlineElem3);
page3.AppendChildLast(outline3);
/*---------- Add pages to the OneNote Document ----------*/
doc.AppendChildLast(page1);
doc.AppendChildLast(page2);
doc.AppendChildLast(page3);
// Save OneNote document
dataDir = dataDir + "CreateDocWithRootAndSubPages_out.one";
doc.Save(dataDir);
Margin
Obtenir o posar la marge.
public Margins Margin { get; set; }
Valor de la propietat
PageContentRevisionSummary
Obté o col·loca el resum de la revisió per a la pàgina i és nodes infantils.
public RevisionSummary PageContentRevisionSummary { get; set; }
Valor de la propietat
Examples
Mostra com editar la meta informació de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document and get first child
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
// Reading Content Revision Summary for this page
var pageRevisionInfo = page.PageContentRevisionSummary;
Console.WriteLine(string.Format(
"Author:\t{0}\nModified:\t{1}",
pageRevisionInfo.AuthorMostRecent,
pageRevisionInfo.LastModifiedTime.ToString("dd.MM.yyyy HH:mm:ss")));
// Update Page Revision Summary for this page
pageRevisionInfo.AuthorMostRecent = "New Author";
pageRevisionInfo.LastModifiedTime = DateTime.Now;
document.Save(dataDir + "WorkingWithPageRevisions_out.one");
Mostra com comprovar si una pàgina és un conflicte (és a dir, té canvis que OneNote no podia fusionar automàticament).
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write(" {0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
i,
historyPage.PageContentRevisionSummary.AuthorMostRecent,
historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
// By default conflict pages are just skipped on saving.
// If mark it as non-conflict then it will be saved as usual one in the history.
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
PageLayoutSize
Obté o s’estableix la mida de layout de la pàgina que es mostra en l’editor.
public SizeF PageLayoutSize { get; set; }
Valor de la propietat
Remarks
Aquest valor s’utilitza per l’aplicació Microsoft OneNote per mostrar el disseny de la pàgina subjacent quan es obre el document.No afecta la impressió i l’estalvi del document en cap cas.Quan la propietat de Page.SizeType s’estableix a PageSiceTYpe.ByContent aquesta propiedad torna la mida real del contingut.
SizeType
Obté o estableix el tipus de mida d’una pàgina.
public PageSizeType SizeType { get; set; }
Valor de la propietat
Remarks
Per defecte, una pàgina es resideix automàticament. El valor de default és Aspose.Note.PageSizeType.SiceByContent.
Title
Obtenir o posar el títol.
public Title Title { get; set; }
Valor de la propietat
Examples
Mostra com obtenir meta informació sobre una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(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();
}
Mostra com editar la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document and get first child
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
var pageHistory = document.GetPageHistory(page);
pageHistory.RemoveRange(0, 1);
pageHistory[0] = new Page(document);
if (pageHistory.Count > 1)
{
pageHistory[1].Title.TitleText.Text = "New Title";
pageHistory.Add(new Page(document));
pageHistory.Insert(1, new Page(document));
document.Save(dataDir + "ModifyPageHistory_out.one");
}
Mostra com configurar un títol per a una pàgina.
string dataDir = RunExamples.GetDataDir_Text();
string outputPath = 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);
Mostra com obtenir la història de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Get first page
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
/*Use pageRevision like a regular page.*/
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();
}
Mostra com crear un document i salvar-lo en format html utilitzant les opcions de default.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
Mostra com crear un document i guardar en format html la gamma de pàgines especificades.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
Mostra com crear un document amb una pàgina titulada.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Create an object of the Document class
Document doc = new Aspose.Note.Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Set page title properties
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
// Append Page node in the document
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "CreateDocWithPageTitle_out.one";
doc.Save(dataDir);
Mostra com guardar un document en diferents formats.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize the new Document
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
// Initialize the new Page
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
// Append page node
doc.AppendChildLast(page);
// Save OneNote document in different formats, set text font size and detect layout changes manually.
doc.Save(dataDir + "ConsequentExportOperations_out.html");
doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
textStyle.FontSize = 11;
doc.DetectLayoutChanges();
doc.Save(dataDir + "ConsequentExportOperations_out.bmp");
Methods
Accept(DocumentVisitor)
Accepta el visitant del nucli.
public override void Accept(DocumentVisitor visitor)
Parameters
visitor
DocumentVisitor
L’objecte d’una classe derivat del Aspose.Note.DocumentVisitor.
Clone(La botiga)
Clona la pàgina.
public Page Clone(bool cloneHistory = false)
Parameters
cloneHistory
bool
Especifica si la història de la pàgina ha de ser clonada.
Returns
Una clona de la pàgina.
Examples
Mostra com empènyer la versió actual d’una pàgina a la història.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document and get first child
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
var pageHistory = document.GetPageHistory(page);
pageHistory.Add(page.Clone());
document.Save(dataDir + "PushCurrentPageVersion_out.one");
Com clonar una pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load OneNote document
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
// Clone into new document without history
var cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone());
// Clone into new document with history
cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone(true));
Càlculs ()
Obtenir tots els nuclis infantils de la pàgina pel tipus de nucli.
public override List<t1> GetChildNodes<t1>() where T1 : class, INode
Returns
Una llista de nodes infantils.
Tipus de paràmetres
T1
El tipus d’elements de la llista retornada.
Examples
Mostra com obtenir tot el text del document.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Retrieve text
string text = string.Join(Environment.NewLine, oneFile.GetChildNodes<richtext>().Select(e => e.Text)) + Environment.NewLine;
// Print text on the output screen
Console.WriteLine(text);</richtext>
Mostra com obtenir tot el text de la pàgina.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get list of page nodes
var page = oneFile.GetChildNodes<page>().FirstOrDefault();
if (page != null)
{
// Retrieve text
string text = string.Join(Environment.NewLine, page.GetChildNodes<richtext>().Select(e => e.Text)) + Environment.NewLine;
// Print text on the output screen
Console.WriteLine(text);
}</richtext></page>
Mostra com passar per totes les pàgines i fer una substitució en el text.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string=""> replacements = new Dictionary<string, string="">();
replacements.Add("Some task here", "New Text Here");
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all RichText nodes
IList<richtext> textNodes = oneFile.GetChildNodes<richtext>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string=""> kvp in replacements)
{
// Replace text of a shape
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir = dataDir + "ReplaceTextOnAllPages_out.pdf";
// Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf);</string,></richtext></richtext></string,></string,>
Mostra com passar pel text de la pàgina i fer una substitució.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string=""> replacements = new Dictionary<string, string="">();
replacements.Add("voice over", "voice over new text");
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
IList<page> pageNodes = oneFile.GetChildNodes<page>();
// Get all RichText nodes
IList<richtext> textNodes = pageNodes[0].GetChildNodes<richtext>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string=""> kvp in replacements)
{
// Replace text of a shape
richText.Replace(kvp.Key, kvp.Value);
}
}
// Save to any supported file format
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);</string,></richtext></richtext></page></page></string,></string,>