Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 16, 2020 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/f1c4460425d3a75dd63cd514a9833946 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/f1c4460425d3a75dd63cd514a9833946 to your computer and use it in GitHub Desktop.
Aspose.Note for .NET
Aspose.Note for .NET
// Instantiate the License class
Aspose.Note.License license = new Aspose.Note.License();
// Pass only the name of the license file embedded in the assembly
license.SetLicense("Aspose.Note.lic");
Aspose.Note.License license = new Aspose.Note.License();
license.SetLicense("Aspose.Note.lic");
Aspose.Note.License license = new Aspose.Note.License();
FileStream myStream = new FileStream("Aspose.Note.lic", FileMode.Open);
license.SetLicense(myStream);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Attachments();
// 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);
// Initialize AttachedFile class object and also pass its icon path
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", File.OpenRead(dataDir + "icon.jpg"), ImageFormat.Jpeg);
// Add attached file
outlineElem.AppendChildLast(attachedFile);
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
dataDir = dataDir + "AttachFileAndSetIcon_out.one";
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Attachments();
// 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);
// Initialize AttachedFile class object
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");
// Add attached file
outlineElem.AppendChildLast(attachedFile);
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
dataDir = dataDir + "AttachFileByPath_out.one";
doc.Save(dataDir);
private static void CopyStream(Stream input, Stream output)
{
try
{
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Attachments();
// Load the document into Aspose.Note.
Document oneFile = new Document( dataDir + "Sample1.one");
// Get a list of attached file nodes
IList<AttachedFile> nodes = oneFile.GetChildNodes<AttachedFile>();
// Iterate through all nodes
foreach (AttachedFile file in nodes)
{
// Load attached file to a stream object
using (Stream outputStream = new MemoryStream(file.Bytes))
{
// Create a local file
using (Stream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
{
// Copy file stream
CopyStream(outputStream, fileStream);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// 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 and set offset properties
Outline outline = new Outline(doc) { VerticalOffset = 0, HorizontalOffset = 0 };
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image by the file path.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg");
// Set image alignment
image.Alignment = HorizontalAlignment.Right;
// Add image
outlineElem.AppendChildLast(image);
// Add outline elements
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline1 = new Outline(doc) { VerticalOffset = 600, HorizontalOffset = 0 };
OutlineElement outlineElem1 = new OutlineElement(doc);
FileStream fs = File.OpenRead(dataDir + "image.jpg");
// Load the second image using the image name, extension and stream.
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs);
// Set image alignment
image1.Alignment = HorizontalAlignment.Right;
outlineElem1.AppendChildLast(image1);
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<Aspose.Note.Image> nodes = oneFile.GetChildNodes<Aspose.Note.Image>();
foreach (Aspose.Note.Image image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
// Save image bytes to a file
bitMap.Save(String.Format(dataDir + "{0}", Path.GetFileName(image.FileName)));
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<Aspose.Note.Image> images = oneFile.GetChildNodes<Aspose.Note.Image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg");
image.AlternativeTextTitle = "This is an image's title!";
image.AlternativeTextDescription = "And this is an image's description!";
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir = dataDir + "ImageAlternativeText_out.one";
document.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg");
// Change the image's size according to your needs (optional).
image.Width = 100;
image.Height = 100;
// Set the image's location in the page (optional).
image.VerticalOffset = 400;
image.HorizontalOffset = 100;
// Set image alignment
image.Alignment = HorizontalAlignment.Right;
// Add the image to the page.
page.AppendChildLast(image);
// 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");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Initialize ImageSaveOptions object
ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png);
// Set page index
opts.PageIndex = 1;
dataDir = dataDir + "ConvertSpecificPageToImage_out.png";
// Save the document as PNG.
oneFile.Save(dataDir, opts);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document doc = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
// Save the document.
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Quality = 100 });
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document doc = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
// Save the document.
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Resolution = 220 });
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 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 Title class object
Title title = new Title(doc);
// Initialize TextStyle class object and set formatting properties
ParagraphStyle defaultTextStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText titleText = new RichText(doc)
{
Text = "Title!",
ParagraphStyle = defaultTextStyle
};
Outline outline = new Outline(doc)
{
VerticalOffset = 100,
HorizontalOffset = 100
};
OutlineElement outlineElem = new OutlineElement(doc);
// RunIndex = 5 means the style will be applied only to 0-4 characters. ("Hello")
TextStyle textStyleForHelloWord = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10,
RunIndex = 5,
};
// RunIndex = 13 means the style will be applied only to 5-12 characters. (" OneNote")
TextStyle textStyleForOneNoteWord = new TextStyle
{
FontColor = Color.Green,
FontName = "Calibri",
FontSize = 10,
IsItalic = true,
RunIndex = 13,
};
// RunIndex = 18 means the style will be applied only to 13-17 characters. (" text").
// Other characters ("!") will have the default style.
TextStyle textStyleForTextWord = new TextStyle
{
FontColor = Color.Blue,
FontName = "Arial",
FontSize = 15,
IsBold = true,
IsItalic = true,
RunIndex = 18,
};
RichText text = new RichText(doc)
{
Text = "Hello OneNote text!",
ParagraphStyle = defaultTextStyle,
Styles = { textStyleForHelloWord, textStyleForOneNoteWord, textStyleForTextWord }
};
title.TitleText = titleText;
// Set page title
page.Title = title;
// Add RichText node
outlineElem.AppendChildLast(text);
// Add OutlineElement node
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
// Save OneNote document
doc.Save(dataDir);
// 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);
dataDir = dataDir + "CreateDocWithPageTitle_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Page page = new Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Initialize TextStyle class object and set formatting properties
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Initialize RichText class object and apply text style
RichText text = new RichText(doc) { Text = "Hello OneNote text!", ParagraphStyle = textStyle };
// Add RichText node
outlineElem.AppendChildLast(text);
// Add OutlineElement node
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
dataDir = dataDir + "CreateDocWithSimpleRichText_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
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 }
};
doc.AppendChildLast(page);
dataDir = dataDir + "CreateAndSavePageRange_out.html";
// Save as HTML format
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
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 }
};
doc.AppendChildLast(page);
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
// Save as HTML format
doc.Save(dataDir);
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
// This code creates documentFolder containing document.html, css folder with style.css file, images folder with images and fonts folder with fonts.
// style.css file will contains at the end the following string "/* This line is appended to stream manually by user */"
var options = new HtmlSaveOptions()
{
FontFaceTypes = FontFaceType.Ttf
};
var savingCallbacks = new UserSavingCallbacks()
{
RootFolder = "documentFolder",
CssFolder = "css",
KeepCssStreamOpened = true,
ImagesFolder = "images",
FontsFolder = "fonts"
};
options.CssSavingCallback = savingCallbacks;
options.FontSavingCallback = savingCallbacks;
options.ImageSavingCallback = savingCallbacks;
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Open the document we want to convert.
Document doc = new Document(dataDir + "Aspose.one");
// Create an object that inherits from the DocumentVisitor class.
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
// This is the well known Visitor pattern. Get the model to accept a visitor.
// The model will iterate through itself by calling the corresponding methods
// on the visitor object (this is called visiting).
//
// Note that every node in the object model has the Accept method so the visiting
// can be executed not only for the whole document, but for any node in the document.
doc.Accept(myConverter);
// Once the visiting is complete, we can retrieve the result of the operation,
// that in this example, has accumulated in the visitor.
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
/// <summary>
/// Simple implementation of saving a document in the plain text format. Implemented as a Visitor.
/// </summary>
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
nodecount = 0;
mIsSkipText = false;
mBuilder = new StringBuilder();
}
/// <summary>
/// Gets the plain text of the document that was accumulated by the visitor.
/// </summary>
public string GetText()
{
return mBuilder.ToString();
}
/// <summary>
/// Adds text to the current output. Honors the enabled/disabled output flag.
/// </summary>
private void AppendText(string text)
{
if (!mIsSkipText)
mBuilder.Append(text);
}
/// <summary>
/// Called when a RichText node is encountered in the document.
/// </summary>
public override void VisitRichTextStart(RichText run)
{
++nodecount;
AppendText(run.Text);
}
/// <summary>
/// Called when a Document node is encountered in the document.
/// </summary>
public override void VisitDocumentStart(Document document)
{
++nodecount;
}
/// <summary>
/// Called when a Page node is encountered in the document.
/// </summary>
public override void VisitPageStart(Page page)
{
++nodecount;
}
/// <summary>
/// Called when a Title node is encountered in the document.
/// </summary>
public override void VisitTitleStart(Title title)
{
++nodecount;
}
/// <summary>
/// Called when a Image node is encountered in the document.
/// </summary>
public override void VisitImageStart(Image image)
{
++nodecount;
}
/// <summary>
/// Called when a OutlineGroup node is encountered in the document.
/// </summary>
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++nodecount;
}
/// <summary>
/// Called when a Outline node is encountered in the document.
/// </summary>
public override void VisitOutlineStart(Outline outline)
{
++nodecount;
}
/// <summary>
/// Called when a OutlineElement node is encountered in the document.
/// </summary>
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++nodecount;
}
/// <summary>
/// Gets the total count of nodes by the Visitor
/// </summary>
public Int32 NodeCount
{
get { return this.nodecount; }
}
private readonly StringBuilder mBuilder;
private bool mIsSkipText;
private Int32 nodecount;
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = "Open Notebook.onetoc2";
if (fileName != "")
{
try
{
var notebook = new Notebook(dataDir + fileName);
foreach (var notebookChildNode in notebook)
{
Console.WriteLine(notebookChildNode.DisplayName);
if (notebookChildNode is Document)
{
// Do something with child document
}
else if (notebookChildNode is Notebook)
{
// Do something with child notebook
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
else
{
Console.WriteLine("\nPlease enter valid file name.");
}
// The path to the documents directory.
Document doc = new Document();
// Returns NodeType.Document
NodeType type = doc.NodeType;
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(400);
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new AlwaysSplitObjectsAlgorithm();
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm();
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
float heightLimitOfClonedPart = 500;
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(heightLimitOfClonedPart);
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
// For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new AlwaysSplitObjectsAlgorithm();
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm();
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
float heightLimitOfClonedPart = 500;
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(heightLimitOfClonedPart);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
LoadOptions loadOptions = new LoadOptions
{
DocumentPassword = "password"
};
Document doc = new Document(dataDir + "Sample1.one", loadOptions);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
switch (document.FileFormat)
{
case FileFormat.OneNote2010:
// Process OneNote 2010
break;
case FileFormat.OneNoteOnline:
// Process OneNote Online
break;
}
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingOnesaveoptions_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, new OneSaveOptions());
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingSaveFormat_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, SaveFormat.One);
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Initialize PdfSaveOptions object
PdfSaveOptions opts = new PdfSaveOptions();
// Set page index
opts.PageIndex = 0;
// Set page count
opts.PageCount = 1;
dataDir = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
// Save the document as PDF
oneFile.Save(dataDir, opts);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SaveToImageDefaultOptions_out.gif";
// Save the document as gif.
oneFile.Save(dataDir, SaveFormat.Gif);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document doc = new Document(dataDir + "Aspose.one");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
// Rewind the stream position back to zero so it is ready for next reader.
dstStream.Position = 0;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SaveWithDefaultSettings_out.pdf";
// Save the document as PDF
oneFile.Save(dataDir, SaveFormat.Pdf);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document doc = new Document(dataDir + "Aspose.one");
// Initialize PdfSaveOptions object
PdfSaveOptions opts = new PdfSaveOptions();
// Set page index
opts.PageIndex = 2;
// Set page count
opts.PageCount = 3;
//specify compression if required
opts.ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg;
opts.JpegQuality = 90;
dataDir = dataDir + "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
// For complete examples and data files, please go to https://github.com/aspose-note/Aspose.Note-for-.NET
class UserSavingCallbacks : ICssSavingCallback, IFontSavingCallback, IImageSavingCallback
{
public string RootFolder { get; set; }
public bool KeepCssStreamOpened { get; set; }
public string CssFolder { get; set; }
public Stream CssStream { get; private set; }
public string FontsFolder { get; set; }
public string ImagesFolder { get; set; }
public void FontSaving(FontSavingArgs args)
{
string uri;
Stream stream;
this.CreateResourceInFolder(this.FontsFolder, args.FileName, out uri, out stream);
args.Stream = stream;
args.Uri = Path.Combine("..", uri).Replace("\\", "\\\\");
}
public void CssSaving(CssSavingArgs args)
{
string uri;
Stream stream;
this.CreateResourceInFolder(this.CssFolder, args.FileName, out uri, out stream);
args.Stream = this.CssStream = stream;
args.KeepStreamOpen = this.KeepCssStreamOpened;
args.Uri = uri;
}
public void ImageSaving(ImageSavingArgs args)
{
string uri;
Stream stream;
this.CreateResourceInFolder(this.ImagesFolder, args.FileName, out uri, out stream);
args.Stream = stream;
args.Uri = uri;
}
private void CreateResourceInFolder(string folder, string filename, out string uri, out Stream stream)
{
var relativePath = folder;
var fullPath = Path.Combine(this.RootFolder, relativePath);
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(fullPath);
}
stream = File.Create(Path.Combine(fullPath, filename));
uri = Path.Combine(relativePath, filename);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
// Append a new child to the Notebook
notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));
dataDir = dataDir + "AddChildNode_out.onetoc2";
// Save the Notebook
notebook.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
dataDir = dataDir + "ConvertToImage_out.png";
// Save the Notebook
notebook.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch öffnen.onetoc2");
var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png);
var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
documentSaveOptions.Resolution = 400;
notebookSaveOptions.Flatten = true;
dataDir = dataDir + "ConvertToImageAsFlattenedNotebook_out.png";
// Save the Notebook
notebook.Save(dataDir, notebookSaveOptions);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png);
var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
documentSaveOptions.Resolution = 400;
dataDir = dataDir + "ConvertToImageWithOptions_out.png";
// Save the Notebook
notebook.Save(dataDir, notebookSaveOptions);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
dataDir = dataDir + "ConvertToPDF_out.pdf";
// Save the Notebook
notebook.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
dataDir = dataDir + "ConvertToPDFAsFlattened_out.pdf";
// Save the Notebook
notebook.Save(
dataDir,
new NotebookPdfSaveOptions
{
Flatten = true
});
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
var notebookSaveOptions = new NotebookPdfSaveOptions();
var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
documentSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
dataDir = dataDir + "ConvertToPDF_out.pdf";
// Save the Notebook
notebook.Save(dataDir, notebookSaveOptions);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook();
dataDir = dataDir + "test_out.onetoc2";
// Save the Notebook
notebook.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
Document document = new Document();
document.Save(dataDir + "CreatingPasswordProtectedDoc_out.one", new OneSaveOptions() { DocumentPassword = "pass" });
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
FileStream stream = new FileStream(dataDir + "Notizbuch öffnen.onetoc2", FileMode.Open);
var notebook = new Notebook(stream);
FileStream childStream = new FileStream(dataDir + "Aspose.one", FileMode.Open);
notebook.LoadChildDocument(childStream);
notebook.LoadChildDocument(dataDir + "Sample1.one");
string inputFile = "Notizbuch öffnen.onetoc2";
string dataDir = RunExamples.GetDataDir_NoteBook();
// By default children loading is "lazy".
Notebook notebook = new Notebook(dataDir + inputFile);
foreach (INotebookChildNode notebookChildNode in notebook) {
// Actual loading of the child document happens only here.
if (notebookChildNode is Document) {
// Do something with child document
}
}
// By default children loading is "lazy".
// Therefore for instant loading has took place,
// it is necessary to set the NotebookLoadOptions.InstantLoading flag.
NotebookLoadOptions loadOptions = new NotebookLoadOptions();
loadOptions.InstantLoading = true;
String inputFile = "Notizbuch öffnen.onetoc2";
String dataDir = RunExamples.GetDataDir_NoteBook();
Notebook notebook = new Notebook(dataDir + inputFile, loadOptions);
// All child documents are already loaded.
foreach (INotebookChildNode notebookChildNode in notebook) {
if (notebookChildNode is Document) {
// Do something with child document
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "test.onetoc2", new NotebookLoadOptions() { DeferredLoading = true });
notebook.LoadChildDocument(dataDir + "Aspose.one");
notebook.LoadChildDocument(dataDir + "Locked Pass1.one", new LoadOptions() { DocumentPassword = "pass" });
notebook.LoadChildDocument(dataDir + "Locked Pass2.one", new LoadOptions() { DocumentPassword = "pass2" });
string inputFile = "notebook.onetoc2";
string dataDir = RunExamples.GetDataDir_NoteBook();
Notebook rootNotebook = new Notebook(dataDir + inputFile);
IList<RichText> allRichTextNodes = rootNotebook.GetChildNodes<RichText>();
foreach (RichText richTextNode in allRichTextNodes) {
Console.WriteLine(richTextNode.Text);
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
// Load a OneNote Notebook
var notebook = new Notebook(dataDir + "test.onetoc2");
// Traverse through its child nodes for searching the desired child item
foreach (var child in new List<INotebookChildNode>(notebook))
{
if (child.DisplayName == "Remove Me")
{
// Remove the Child Item from the Notebook
notebook.RemoveChild(child);
}
}
dataDir = dataDir + "RemoveChildNode_out.onetoc2";
// Save the Notebook
notebook.Save(dataDir);
string inputFile = "notebook.onetoc2";
string dataDir = RunExamples.GetDataDir_NoteBook();
Notebook rootNotebook = new Notebook(dataDir + inputFile);
IList<Document> allDocuments = rootNotebook.GetChildNodes<Document>();
foreach (Document document in allDocuments) {
Console.WriteLine(document.DisplayName);
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook();
MemoryStream stream = new MemoryStream();
notebook.Save(stream);
if (notebook.Count > 0)
{
var childDocument0 = notebook[0] as Document;
MemoryStream childStream = new MemoryStream();
childDocument0.Save(childStream);
var childDocument1 = notebook[1] as Document;
childDocument0.Save(dataDir + "SaveNotebookToStream_out.one");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "notebook2.onetoc2", new NotebookLoadOptions() { DeferredLoading = false });
notebook.Save(dataDir + "notebook_out.onetoc2", new NotebookOneSaveOptions() { DeferredSaving = true });
if (notebook.Count > 0)
{
var childDocument0 = notebook[0] as Document;
childDocument0.Save(dataDir + "Not Locked_out.one");
var childDocument1 = notebook[1] as Document;
childDocument1.Save(dataDir + "Locked Pass1_out.one", new OneSaveOptions() { DocumentPassword = "pass" });
var childDocument2 = notebook[2] as Document;
childDocument2.Save(dataDir + "Locked Pass2_out.one", new OneSaveOptions() { DocumentPassword = "pass2" });
}
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);
// 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);
dataDir = dataDir + "CreateDocWithRootAndSubPages_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get number of pages
int count = oneFile.GetChildNodes<Page>().Count;
// Print count on the output screen
Console.WriteLine(count);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Page nodes
IList<Page> pages = oneFile.GetChildNodes<Page>();
foreach (Page page in pages)
{
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();
}
// 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();
}
// 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");
}
// 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));
// 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");
// 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;
Page lastPage = null;
foreach (Page pageRevision in document.GetPageHistory(page))
{
lastPage = pageRevision;
}
document.RemoveChild(page);
document.AppendChildLast(lastPage);
document.Save(dataDir + "RollBackRevisions_out.one");
// 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");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
var printerSettings = new PrinterSettings() { FromPage = 0, ToPage = 10 };
printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
document.Print(new PrintOptions()
{
PrinterSettings = printerSettings,
Resolution = 1200,
PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
DocumentName = "Test.one"
});
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// 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 TableRow class object
TableRow row1 = new TableRow(doc);
// Initialize TableCell class object and set text content
TableCell cell11 = new TableCell(doc);
cell11.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Small text"));
row1.AppendChildLast(cell11);
// Initialize TableRow class object
TableRow row2 = new TableRow(doc);
// Initialize TableCell class object and set text content
TableCell cell21 = new TableCell(doc);
cell21.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Long text with several words and spaces."));
row2.AppendChildLast(cell21);
// Initialize Table class object
Table table = new Table(doc)
{
IsBordersVisible = true,
Columns = { new TableColumn { Width = 70, LockedWidth = true } }
};
// Add rows
table.AppendChildLast(row1);
table.AppendChildLast(row2);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
// Add table node
outlineElem.AppendChildLast(table);
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
dataDir = dataDir + "CreateTableWithLockedColumns_out.one";
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// Load the document into Aspose.Note.
Document document = new Document(dataDir + "Sample1.one");
// Get a list of table nodes
IList<Table> nodes = document.GetChildNodes<Table>();
foreach (Table table in nodes)
{
// Iterate through table rows
foreach (TableRow row in table)
{
// Get list of TableCell nodes
IList<TableCell> cellNodes = row.GetChildNodes<TableCell>();
// Iterate through table cells
foreach (TableCell cell in cellNodes)
{
// Retrieve text
string text = string.Join(Environment.NewLine, cell.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
// Print text on the output screen
Console.WriteLine(text);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// Load the document into Aspose.Note.
Document document = new Document(dataDir + "Sample1.one");
// Get a list of table nodes
IList<Table> nodes = document.GetChildNodes<Table>();
// Set row count
int rowCount = 0;
foreach (Table table in nodes)
{
// Iterate through table rows
foreach (TableRow row in table)
{
rowCount++;
// Retrieve text
string text = string.Join(Environment.NewLine, row.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
// Print text on the output screen
Console.WriteLine(text);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// Load the document into Aspose.Note.
Document document = new Document(dataDir + "Sample1.one");
// Get a list of table nodes
IList<Table> nodes = document.GetChildNodes<Table>();
// Set table count
int tblCount = 0;
foreach (Table table in nodes)
{
tblCount++;
Console.WriteLine("table # " + tblCount);
// Retrieve text
string text = string.Join(Environment.NewLine, table.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
// Print text on the output screen
Console.WriteLine(text);
}
public static OutlineElement GetOutlineElementWithText(Document doc, string text)
{
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
outlineElem.AppendChildLast(new RichText(doc) { Text = text, ParagraphStyle = textStyle });
return outlineElem;
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();
// 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 TableRow class object
TableRow row1 = new TableRow(doc);
// Initialize TableCell class objects
TableCell cell11 = new TableCell(doc);
TableCell cell12 = new TableCell(doc);
TableCell cell13 = new TableCell(doc);
// Append outline elements in the table cell
cell11.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.1"));
cell12.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.2"));
cell13.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.3"));
// Table cells to rows
row1.AppendChildLast(cell11);
row1.AppendChildLast(cell12);
row1.AppendChildLast(cell13);
// Initialize TableRow class object
TableRow row2 = new TableRow(doc);
// initialize TableCell class objects
TableCell cell21 = new TableCell(doc);
TableCell cell22 = new TableCell(doc);
TableCell cell23 = new TableCell(doc);
// Append outline elements in the table cell
cell21.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.1"));
cell22.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.2"));
cell23.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.3"));
// Append table cells to rows
row2.AppendChildLast(cell21);
row2.AppendChildLast(cell22);
row2.AppendChildLast(cell23);
// Initialize Table class object and set column widths
Table table = new Table(doc)
{
IsBordersVisible = true,
Columns = { new TableColumn { Width = 200 }, new TableColumn { Width = 200 }, new TableColumn { Width = 200 } }
};
// Append table rows to table
table.AppendChildLast(row1);
table.AppendChildLast(row2);
// Initialize Outline object
Outline outline = new Outline(doc);
// Initialize OutlineElement object
OutlineElement outlineElem = new OutlineElement(doc);
// Add table to outline element node
outlineElem.AppendChildLast(table);
// Add outline element to outline
outline.AppendChildLast(outlineElem);
// Add outline to page node
page.AppendChildLast(outline);
// Add page to document node
doc.AppendChildLast(page);
dataDir = dataDir + "InsertTable_out.one";
doc.Save(dataDir);
// 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 TableRow class object
TableRow row1 = new TableRow(doc);
// Initialize TableCell class object and set text content
TableCell cell11 = new TableCell(doc);
cell11.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Small text"));
cell11.BackgroundColor = Color.Coral;
row1.AppendChildLast(cell11);
// 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(new NoteTag
{
Icon = TagIcon.YellowStar,
});
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
dataDir = dataDir + "AddImageNodeWithTag_out.one";
// Save OneNote document
doc.Save(dataDir);
// 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 TableRow class object
TableRow row = new TableRow(doc);
// Initialize TableCell class object
TableCell cell = new TableCell(doc);
// Insert cell content
cell.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Single cell."));
// Add cell to row node
row.AppendChildLast(cell);
// Initialize table node
Table table = new Table(doc)
{
IsBordersVisible = true,
Columns = { new TableColumn { Width = 70 } }
};
// Insert row node in table
table.AppendChildLast(row);
// Add tag to this table node
table.Tags.Add(new NoteTag
{
Icon = TagIcon.QuestionMark
});
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
// Add table node
outlineElem.AppendChildLast(table);
// Add outline elements
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddTableNodeWithTag_out.one";
// Save OneNote document
doc.Save(dataDir);
// 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);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "OneNote text.", ParagraphStyle = textStyle };
text.Tags.Add(new NoteTag
{
Icon = TagIcon.YellowStar,
});
// Add text node
outlineElem.AppendChildLast(text);
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
dataDir = dataDir + "AddTextNodeWithTag_out.one";
// Save OneNote document
doc.Save(dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tags();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "TagFile.one");
// Get all RichText nodes
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
// Iterate through each node
foreach (RichText richText in nodes)
{
foreach (var tag in richText.Tags)
{
if (tag is NoteTag)
{
NoteTag noteTag = (NoteTag)tag;
// Retrieve properties
Console.WriteLine("Completed Time: " + noteTag.CompletedTime);
Console.WriteLine("Create Time: " + noteTag.CreationTime);
Console.WriteLine("Font Color: " + noteTag.FontColor);
Console.WriteLine("Status: " + noteTag.Status);
Console.WriteLine("Label: " + noteTag.Label);
Console.WriteLine("Icon: " + noteTag.Icon);
Console.WriteLine("High Light: " + noteTag.Highlight);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tasks();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all RichText nodes
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
// Iterate through each node
foreach (RichText richText in nodes)
{
foreach (var tag in richText.Tags)
{
if (tag is NoteTask)
{
NoteTask noteTask = (NoteTask)tag;
// Retrieve properties
Console.WriteLine("Completed Time: " + noteTask.CompletedTime);
Console.WriteLine("Create Time: " + noteTask.CreationTime);
Console.WriteLine("Due Date: " + noteTask.DueDate);
Console.WriteLine("Status: " + noteTask.Status);
Console.WriteLine("Task Type: " + noteTask.TaskType);
Console.WriteLine("Icon: " + noteTask.Icon);
}
}
}
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);
dataDir = dataDir + "ApplyBulletsOnText_out.one";
// Save OneNote document
doc.Save(dataDir);
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);
dataDir = dataDir + "ApplyNumberingOnText_out.one";
// Save OneNote document
doc.Save(dataDir);
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document document = new Document(dataDir + "Aspose.one");
// Get a particular RichText node
IList<RichText> richTextNodes = document.GetChildNodes<RichText>();
RichText richText = richTextNodes[0];
foreach (TextStyle style in richText.Styles)
{
// Set font color
style.FontColor = Color.Yellow;
// Set highlight color
style.Highlight = Color.Blue;
// Set font size
style.FontSize = 20;
}
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);
// 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);
// 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
IList<Node> nodes = oneFile.GetChildNodes<Node>();
if (nodes.Count > 0 && nodes[0].NodeType == NodeType.Page)
{
Page page = (Page)nodes[0];
// 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);
}
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);
dataDir = dataDir + "InsertChineseNumberList_out.one";
// Save OneNote document
doc.Save(dataDir);
// 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)
{
if (richText != null && richText.Text.Contains(kvp.Key))
{
// Replace text of a shape
richText.Text = richText.Text.Replace(kvp.Key, kvp.Value);
}
}
}
dataDir = dataDir + "ReplaceTextOnAllPages_out.pdf";
// Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf);
// 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)
{
if (richText != null && richText.Text.Contains(kvp.Key))
{
// Replace text of a shape
richText.Text = richText.Text.Replace(kvp.Key, kvp.Value);
}
}
}
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
// Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf);
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "ApplyNumberingOnText.one");
// Retrieve a collection nodes of the outline element
IList<OutlineElement> nodes = oneFile.GetChildNodes<OutlineElement>();
// Iterate through each node
foreach (OutlineElement node in nodes)
{
if (node.NumberList != null)
{
NumberList list = node.NumberList;
// Retrieve font name
Console.WriteLine("Font Name: " + list.Font);
// Retrieve font length
Console.WriteLine("Font Length: " + list.Font.Length);
// Retrieve font size
Console.WriteLine("Font Size: " + list.FontSize);
// Retrieve font color
Console.WriteLine("Font Color: " + list.FontColor);
// Retrieve format
Console.WriteLine("Font format: " + list.Format);
// Check bold
Console.WriteLine("Is bold: " + list.IsBold);
// Check italic
Console.WriteLine("Is italic: " + list.IsItalic);
Console.WriteLine();
}
}
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' Instantiate the License class
Dim license As New Aspose.Note.License()
' Pass only the name of the license file embedded in the assembly
license.SetLicense("Aspose.Note.lic")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim license As New Aspose.Note.License()
license.SetLicense("Aspose.Note.lic")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim license As New Aspose.Note.License()
Dim myStream As New FileStream("Aspose.Note.lic", FileMode.Open)
license.SetLicense(myStream)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Attachments()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
' Initialize AttachedFile class object and also pass its icon path
Dim attachedFile As New AttachedFile(doc, dataDir & Convert.ToString("attachment.txt"), File.OpenRead(dataDir & Convert.ToString("icon.jpg")), ImageFormat.Jpeg)
' Add attached file
outlineElem.AppendChild(attachedFile)
' Add outline element node
outline.AppendChild(outlineElem)
' Add outline node
page.AppendChild(outline)
' Add page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("AttachFileAndSetIcon_out.one")
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Attachments()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
' Initialize AttachedFile class object
Dim attachedFile As New AttachedFile(doc, dataDir & Convert.ToString("attachment.txt"))
' Add attached file
outlineElem.AppendChild(attachedFile)
' Add outline element node
outline.AppendChild(outlineElem)
' Add outline node
page.AppendChild(outline)
' Add page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("AttachFileByPath_out.one")
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Private Shared Sub CopyStream(input As Stream, output As Stream)
Try
Dim buffer As Byte() = New Byte(8 * 1024 - 1) {}
Dim len As Integer
While (InlineAssignHelper(len, input.Read(buffer, 0, buffer.Length))) > 0
output.Write(buffer, 0, len)
End While
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Attachments()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Sample1.one"))
' Get a list of attached file nodes
Dim nodes As IList(Of AttachedFile) = oneFile.GetChildNodes(Of AttachedFile)()
' Iterate through all nodes
For Each file As AttachedFile In nodes
' Load attached file to a stream object
Using outputStream As Stream = New MemoryStream(file.Bytes)
' Create a local file
Using fileStream As Stream = System.IO.File.OpenWrite([String].Format(dataDir + file.FileName))
' Copy file stream
CopyStream(outputStream, fileStream)
End Using
End Using
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object and set offset properties
Dim outline As New Outline(doc) With {
.VerticalOffset = 0,
.HorizontalOffset = 0
}
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
' Load an image by the file path.
Dim image As New Image(doc, dataDir & Convert.ToString("image.jpg"))
' Set image alignment
image.Alignment = HorizontalAlignment.Right
' Add image
outlineElem.AppendChild(image)
' Add outline elements
Outline.AppendChild(outlineElem)
' Add Outline node
page.AppendChild(Outline)
' Add Page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("BuildDocAndInsertImage_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
Dim outline1 As New Outline(doc) With {
.VerticalOffset = 600,
.HorizontalOffset = 0
}
Dim outlineElem1 As New OutlineElement(doc)
Dim fs As FileStream = File.OpenRead(dataDir & Convert.ToString("image.jpg"))
' Load the second image using the image name, extension and stream.
Dim image1 As New Image(doc, "Penguins", "jpg", fs)
' Set image alignment
image1.Alignment = HorizontalAlignment.Right
outlineElem1.AppendChild(image1)
outline1.AppendChild(outlineElem1)
page.AppendChild(outline1)
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("BuildDocAndInsertImageUsingImageStream_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get all Image nodes
Dim nodes As IList(Of Image) = oneFile.GetChildNodes(Of Image)()
For Each image As Image In nodes
Using stream As New MemoryStream(image.Bytes)
Using bitMap As New Bitmap(stream)
' Save image bytes to a file
bitMap.Save([String].Format(dataDir & Convert.ToString("{0}"), Path.GetFileName(image.FileName)))
End Using
End Using
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get all Image nodes
Dim images As IList(Of Image) = oneFile.GetChildNodes(Of Image)()
For Each image As Image In images
Console.WriteLine("Width: {0}", image.Width)
Console.WriteLine("Height: {0}", image.Height)
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth)
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight)
Console.WriteLine("FileName: {0}", image.FileName)
Console.WriteLine("Extension: {0}", image.Extension)
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime)
Console.WriteLine()
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
Dim document = New Document()
Dim page = New Page(document)
Dim image = New Image(document, dataDir & Convert.ToString("image.jpg"))
image.AlternativeText = "ImageAlternativeText"
page.AppendChild(image)
document.AppendChild(page)
dataDir = dataDir & Convert.ToString("ImageAlternativeText_out.one")
document.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Images()
' Load document from the stream.
Dim doc As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get the first page of the document.
Dim page As Page = doc.FirstChild
' Load an image from the file.
Dim image As New Image(doc, dataDir & Convert.ToString("image.jpg"))
' Change the image's size according to your needs (optional).
image.Width = 100
image.Height = 100
' Set the image's location in the page (optional).
image.VerticalOffset = 400
image.HorizontalOffset = 100
' Set image alignment
image.Alignment = HorizontalAlignment.Right
' Add the image to the page.
page.AppendChild(image)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Initialize the new Document
Dim doc As New Document() With {.AutomaticLayoutChangesDetectionEnabled = False}
' Initialize the new Page
Dim page As New Page(doc)
' Default style for all text in the document.
Dim textStyle As New TextStyle() With {.FontColor = System.Drawing.Color.Black, .FontName = "Arial", .FontSize = 10}
page.Title = New Title(doc) With
{
.TitleText = New RichText(doc) With {.Text = "Title text.", .DefaultStyle = textStyle},
.TitleDate = New RichText(doc) With {.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), .DefaultStyle = textStyle},
.TitleTime = New RichText(doc) With {.Text = "12:34", .DefaultStyle = textStyle}
}
' Append page node
doc.AppendChild(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")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Initialize ImageSaveOptions object
Dim opts As New ImageSaveOptions(SaveFormat.Png)
' Set page index
opts.PageIndex = 1
dataDir = dataDir & Convert.ToString("ConvertSpecificPageToImage_out.png")
' Save the document as PNG.
oneFile.Save(dataDir, opts)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim doc As New Document(dataDir & Convert.ToString("Aspose.one"))
dataDir = dataDir & Convert.ToString("SetOutputImageResolution_out.jpg")
' Save the document.
doc.Save(dataDir, New ImageSaveOptions(SaveFormat.Jpeg) With {.Resolution = 220})
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Title class object
Dim title As New Title(doc)
' Initialize TextStyle class object and set formatting properties
Dim defaultTextStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
Dim titleText As New RichText(doc) With {
.Text = "Title!",
.DefaultStyle = defaultTextStyle
}
Dim outline As New Outline(doc) With {
.VerticalOffset = 100,
.HorizontalOffset = 100
}
Dim outlineElem As New OutlineElement(doc)
' RunIndex = 5 means the style will be applied only to 0-4 characters. ("Hello")
Dim textStyleForHelloWord As New TextStyle() With {
.FontColor = Color.Red,
.FontName = "Arial",
.FontSize = 10,
.RunIndex = 5
}
' RunIndex = 13 means the style will be applied only to 5-12 characters. (" OneNote")
Dim textStyleForOneNoteWord As New TextStyle() With {
.FontColor = Color.Green,
.FontName = "Calibri",
.FontSize = 10,
.IsItalic = True,
.RunIndex = 13
}
' RunIndex = 18 means the style will be applied only to 13-17 characters. (" text").
' Other characters ("!") will have the default style.
Dim textStyleForTextWord As New TextStyle() With {
.FontColor = Color.Blue,
.FontName = "Arial",
.FontSize = 15,
.IsBold = True,
.IsItalic = True,
.RunIndex = 18
}
Dim text As New RichText(doc) With {
.Text = "Hello OneNote text!",
.DefaultStyle = defaultTextStyle
}
title.TitleText = titleText
' Set page title
page.Title = title
' Add RichText node
outlineElem.AppendChild(Text)
' Add OutlineElement node
Outline.AppendChild(outlineElem)
' Add Outline node
page.AppendChild(Outline)
' Add Page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("CreateDocWithFormattedRichText_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Create an object of the Document class
Dim doc As Document = New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Default style for all text in the document.
Dim textStyle As TextStyle = New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
' Set page title properties
page.Title = New Title(doc) With {
.TitleText = New RichText(doc) With {
.Text = "Title text.",
.DefaultStyle = textStyle
},
.TitleDate = New RichText(doc) With {
.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
.DefaultStyle = textStyle
},
.TitleTime = New RichText(doc) With {
.Text = "12:34",
.DefaultStyle = textStyle
}
}
' Append Page node in the document
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("CreateDocWithPageTitle_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
' Initialize TextStyle class object and set formatting properties
Dim textStyle As New TextStyle() With {.FontColor = Color.Black, .FontName = "Arial", .FontSize = 10}
' Initialize RichText class object and apply text style
Dim text As New RichText(doc) With {.Text = "Hello OneNote text!", .DefaultStyle = textStyle}
' Add RichText node
outlineElem.AppendChild(text)
' Add OutlineElement node
outline.AppendChild(outlineElem)
' Add Outline node
page.AppendChild(outline)
' Add Page node
doc.AppendChild(page)
dataDir = dataDir + "CreateDocWithSimpleRichText_out.one"
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Initialize OneNote document
Dim doc As New Document()
Dim page As New Page(doc)
' Default style for all text in the document.
Dim textStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
page.Title = New Title(doc) With {
.TitleText = New RichText(doc) With {
.Text = "Title text.",
.DefaultStyle = textStyle
},
.TitleDate = New RichText(doc) With {
.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
.DefaultStyle = textStyle
},
.TitleTime = New RichText(doc) With {
.Text = "12:34",
.DefaultStyle = textStyle
}
}
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("CreateAndSavePageRange_out.html")
' Save as HTML format
doc.Save(dataDir, New HtmlSaveOptions() With {
.PageCount = 1,
.PageIndex = 0
})
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Initialize OneNote document
Dim doc As New Document()
Dim page As New Page(doc)
' Default style for all text in the document.
Dim textStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
page.Title = New Title(doc) With {
.TitleText = New RichText(doc) With {
.Text = "Title text.",
.DefaultStyle = textStyle
},
.TitleDate = New RichText(doc) With {
.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
.DefaultStyle = textStyle
},
.TitleTime = New RichText(doc) With {
.Text = "12:34",
.DefaultStyle = textStyle
}
}
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("CreateOneNoteDocAndSaveToHTML_out.html")
' Save as HTML format
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Open the document we want to convert.
Dim doc As New Document(dataDir & Convert.ToString("Aspose.one"))
' Create an object that inherits from the DocumentVisitor class.
Dim myConverter As New MyOneNoteToTxtWriter()
' This is the well known Visitor pattern. Get the model to accept a visitor.
' The model will iterate through itself by calling the corresponding methods
' on the visitor object (this is called visiting).
'
' Note that every node in the object model has the Accept method so the visiting
' can be executed not only for the whole document, but for any node in the document.
doc.Accept(myConverter)
' Once the visiting is complete, we can retrieve the result of the operation,
' that in this example, has accumulated in the visitor.
Console.WriteLine(myConverter.GetText())
Console.WriteLine(myConverter.NodeCount)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
Dim fileName As String = ""
If fileName <> "" Then
Try
Dim notebook = New Notebook(dataDir & fileName)
For Each notebookChildNode In notebook
Console.WriteLine(notebookChildNode.DisplayName)
' Do something with child document
If TypeOf notebookChildNode Is Document Then
' Do something with child notebook
ElseIf TypeOf notebookChildNode Is Notebook Then
End If
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Else
Console.WriteLine(vbLf & "Please enter valid file name.")
End If
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim doc As New Document()
' Returns NodeType.Document
Dim type As NodeType = doc.NodeType
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = New KeepPartAndCloneSolidObjectToNextPageAlgorithm(100)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = New KeepPartAndCloneSolidObjectToNextPageAlgorithm(400)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim pdfSaveOptions = New PdfSaveOptions()
pdfSaveOptions.PageSplittingAlgorithm = New AlwaysSplitObjectsAlgorithm()
' Or
pdfSaveOptions.PageSplittingAlgorithm = New KeepPartAndCloneSolidObjectToNextPageAlgorithm()
' Or
pdfSaveOptions.PageSplittingAlgorithm = New KeepSolidObjectsAlgorithm()
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim heightLimitOfClonedPart As Single = 500
pdfSaveOptions.PageSplittingAlgorithm = New KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart)
' Or
pdfSaveOptions.PageSplittingAlgorithm = New KeepSolidObjectsAlgorithm(heightLimitOfClonedPart)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = New KeepSolidObjectsAlgorithm(100)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
pdfSaveOptions.PageSplittingAlgorithm = New KeepSolidObjectsAlgorithm(400)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
Dim loadOptions As New LoadOptions() With {
.DocumentPassword = "password"
}
Dim doc As New Document(dataDir & Convert.ToString("Sample1.one"), loadOptions)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
Dim document = New Document(dataDir & Convert.ToString("Aspose.one"))
Select Case document.FileFormat
Case FileFormat.OneNote2010
' process OneNote 2010
Exit Select
Case FileFormat.OneNoteOnline
' process OneNote Online
Exit Select
End Select
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Initialize PdfSaveOptions object
Dim opts As New PdfSaveOptions()
' Set page index
opts.PageIndex = 0
' Set page count
opts.PageCount = 1
dataDir = dataDir & Convert.ToString("SaveRangeOfPagesAsPDF_out.pdf")
' Save the document as PDF
oneFile.Save(dataDir, opts)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
dataDir = dataDir & Convert.ToString("SaveToImageDefaultOptions_out.gif")
' Save the document as gif.
oneFile.Save(dataDir, SaveFormat.Gif)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim doc As New Document(dataDir & Convert.ToString("Aspose.one"))
Dim dstStream As New MemoryStream()
doc.Save(dstStream, SaveFormat.Pdf)
' Rewind the stream position back to zero so it is ready for next reader.
dstStream.Position = 0
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
dataDir = dataDir & Convert.ToString("SaveWithDefaultSettings_out.pdf")
' Save the document as PDF
oneFile.Save(dataDir, SaveFormat.Pdf)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_LoadingAndSaving()
' Load the document into Aspose.Note.
Dim doc As New Document(dataDir & Convert.ToString("Aspose.one"))
' Initialize PdfSaveOptions object
Dim opts As New PdfSaveOptions()
' Set page index
opts.PageIndex = 2
' Set page count
opts.PageCount = 3
dataDir = dataDir & Convert.ToString("Document.SaveWithOptions_out.pdf")
doc.Save(dataDir, opts)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
' Append a new child to the Notebook
notebook.AppendChild(New Document(dataDir & Convert.ToString("Neuer Abschnitt 1.one")))
dataDir = dataDir & Convert.ToString("AddChildNode_out.onetoc2")
' Save the Notebook
notebook.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
dataDir = dataDir & Convert.ToString("ConvertToImage_out.png")
' Save the Notebook
notebook.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
Dim notebookSaveOptions = New NotebookImageSaveOptions(SaveFormat.Png)
Dim documentSaveOptions = notebookSaveOptions.DocumentSaveOptions
documentSaveOptions.Resolution = 400
dataDir = dataDir & Convert.ToString("ConvertToImageWithOptions_out.png")
' Save the Notebook
notebook.Save(dataDir, notebookSaveOptions)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
dataDir = dataDir & Convert.ToString("ConvertToPDF_out.pdf")
' Save the Notebook
notebook.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
dataDir = dataDir & Convert.ToString("ConvertToPDFAsFlattened_out.pdf")
' Save the Notebook
notebook.Save(dataDir, New NotebookPdfSaveOptions() With {
.Flatten = True
})
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("Notizbuch öffnen.onetoc2"))
Dim notebookSaveOptions = New NotebookPdfSaveOptions()
Dim documentSaveOptions = notebookSaveOptions.DocumentSaveOptions
documentSaveOptions.PageSplittingAlgorithm = New KeepSolidObjectsAlgorithm()
dataDir = dataDir & Convert.ToString("ConvertToPDF_out.pdf")
' Save the Notebook
notebook.Save(dataDir, notebookSaveOptions)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim notebook = New Notebook()
dataDir = dataDir & Convert.ToString("test_out.onetoc2")
' Save the Notebook
notebook.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim document As New Document()
document.Save(dataDir & Convert.ToString("CreatingPasswordProtectedDoc_out.one"), New OneSaveOptions() With {
.DocumentPassword = "pass"
})
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim stream As New FileStream(dataDir & Convert.ToString("notebook.onetoc2"), FileMode.Open)
Dim notebook = New Notebook(stream)
Dim childStream As New FileStream(dataDir & Convert.ToString("Aspose.one"), FileMode.Open)
notebook.LoadChildDocument(childStream)
notebook.LoadChildDocument(dataDir & Convert.ToString("Sample1.one"))
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim notebook = New Notebook(dataDir & Convert.ToString("test.onetoc2"), New NotebookLoadOptions() With {
.DeferredLoading = True
})
notebook.LoadChildDocument(dataDir & Convert.ToString("Aspose.one"))
notebook.LoadChildDocument(dataDir & Convert.ToString("Locked Pass1.one"), New LoadOptions() With {
.DocumentPassword = "pass"
})
notebook.LoadChildDocument(dataDir & Convert.ToString("Locked Pass2.one"), New LoadOptions() With {
.DocumentPassword = "pass2"
})
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
' Load a OneNote Notebook
Dim notebook = New Notebook(dataDir & Convert.ToString("test.onetoc2"))
' Traverse through its child nodes for searching the desired child item
For Each child In New List(Of INotebookChildNode)(notebook)
If child.DisplayName = "Remove Me" Then
' Remove the Child Item from the Notebook
notebook.RemoveChild(child)
End If
Next
dataDir = dataDir & Convert.ToString("RemoveChildNode_out.onetoc2")
' Save the Notebook
notebook.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim notebook = New Notebook()
Dim stream As New MemoryStream()
notebook.Save(stream)
If notebook.Count > 0 Then
Dim childDocument0 = TryCast(notebook(0), Document)
Dim childStream As New MemoryStream()
childDocument0.Save(childStream)
Dim childDocument1 = TryCast(notebook(1), Document)
childDocument0.Save(dataDir & Convert.ToString("SaveNotebookToStream_out.one"))
End If
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_NoteBook()
Dim notebook = New Notebook(dataDir & Convert.ToString("notebook2.onetoc2"), New NotebookLoadOptions() With {
.DeferredLoading = False
})
notebook.Save(dataDir & Convert.ToString("notebook_out.onetoc2"), New NotebookOneSaveOptions() With {
.DeferredSaving = True
})
If Notebook.Count > 0 Then
Dim childDocument0 = TryCast(Notebook(0), Document)
childDocument0.Save(dataDir & Convert.ToString("Not Locked_out.one"))
Dim childDocument1 = TryCast(Notebook(1), Document)
childDocument1.Save(dataDir & Convert.ToString("Locked Pass1_out.one"), New OneSaveOptions() With {
.DocumentPassword = "pass"
})
Dim childDocument2 = TryCast(Notebook(2), Document)
childDocument2.Save(dataDir & Convert.ToString("Locked Pass2_out.one"), New OneSaveOptions() With {
.DocumentPassword = "pass2"
})
End If
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object and set its level
Dim page1 As New Page(doc) With {
.Level = 1
}
' Initialize Page class object and set its level
Dim page2 As New Page(doc) With {
.Level = 2
}
' Initialize Page class object and set its level
Dim page3 As New Page(doc) With {
.Level = 1
}
'---------- Adding nodes to first Page ----------
Dim outline As New Outline(doc)
Dim outlineElem As New OutlineElement(doc)
Dim textStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
Dim text As New RichText(doc) With {
.Text = "First page.",
.DefaultStyle = textStyle
}
outlineElem.AppendChild(text)
outline.AppendChild(outlineElem)
page1.AppendChild(outline)
'---------- Adding nodes to second Page ----------
Dim outline2 = New Outline(doc)
Dim outlineElem2 = New OutlineElement(doc)
Dim textStyle2 = New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
Dim text2 = New RichText(doc) With {
.Text = "Second page.",
.DefaultStyle = textStyle2
}
outlineElem2.AppendChild(text2)
outline2.AppendChild(outlineElem2)
page2.AppendChild(outline2)
'---------- Adding nodes to third Page ----------
Dim outline3 = New Outline(doc)
Dim outlineElem3 = New OutlineElement(doc)
Dim textStyle3 = New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
Dim text3 = New RichText(doc) With {
.Text = "Third page.",
.DefaultStyle = textStyle3
}
outlineElem3.AppendChild(text3)
outline3.AppendChild(outlineElem3)
page3.AppendChild(outline3)
'---------- Add pages to the OneNote Document ----------
doc.AppendChild(page1)
doc.AppendChild(page2)
doc.AppendChild(page3)
dataDir = dataDir & Convert.ToString("CreateDocWithRootAndSubPages_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get number of pages
Dim count As Integer = oneFile.GetChildNodes(Of Page)().Count
' Print count on the output screen
Console.WriteLine(count)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get all Page nodes
Dim pages As IList(Of Page) = oneFile.GetChildNodes(Of Page)()
For Each page As Page In pages
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()
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load OneNote document
Dim document As New Document(dataDir & Convert.ToString("Aspose.one"), New LoadOptions() With {
.LoadHistory = True
})
' Get first page
Dim firstPage As Page = Document.FirstChild
For Each pageRevision As Page 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()
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load OneNote document and get first child
Dim document As New Document(dataDir & "Aspose.one")
Dim page As Page = document.FirstChild
Dim pageHistory = document.GetPageHistory(page)
pageHistory.RemoveRange(0, 1)
pageHistory(0) = New Page(document)
If pageHistory.Count > 1 Then
pageHistory(1).Title.TitleText.Text = "New Title"
pageHistory.Add(New Page(document))
pageHistory.Insert(1, New Page(document))
document.Save(dataDir & "ModifyPageHistory_out.one")
End If
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load OneNote document and get first child
Dim document As New Document(dataDir & Convert.ToString("Aspose.one"))
Dim page As Page = document.FirstChild
Dim pageHistory = document.GetPageHistory(page)
pageHistory.Add(page.Clone())
document.Save(dataDir & "PushCurrentPageVersion_out.one")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load OneNote document and get first child
Dim document As New Document(dataDir & Convert.ToString("Aspose.one"))
Dim page As Page = document.FirstChild
Dim lastPage As Page = Nothing
For Each pageRevision As Page In document.GetPageHistory(page)
lastPage = pageRevision
Next
document.RemoveChild(page)
document.AppendChild(lastPage)
document.Save(dataDir & "RollBackRevisions_out.one")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Pages()
' Load OneNote document and get first child
Dim document As New Document(dataDir & Convert.ToString("Aspose.one"))
Dim page As Page = document.FirstChild
' Reading Content Revision Summary for this page
Dim pageRevisionInfo = page.PageContentRevisionSummary
Console.WriteLine(String.Format("Author:" & vbTab & "{0}" & vbLf & "Modified:" & vbTab & "{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")
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tables()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize TableRow class object
Dim row1 As New TableRow(doc)
' Initialize TableCell class object and set text content
Dim cell11 As New TableCell(doc)
cell11.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Small text"))
row1.AppendChild(cell11)
' Initialize TableRow class object
Dim row2 As New TableRow(doc)
' Initialize TableCell class object and set text content
Dim cell21 As New TableCell(doc)
cell21.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Long text with several words and spaces."))
row2.AppendChild(cell21)
' Initialize Table class object
Dim table As New Table(doc) With {.IsBordersVisible = True}
' Add rows
Table.AppendChild(row1)
Table.AppendChild(row2)
Dim outline As New Outline(doc)
Dim outlineElem As New OutlineElement(doc)
' Add table node
outlineElem.AppendChild(Table)
' Add outline element node
outline.AppendChild(outlineElem)
' Add outline node
page.AppendChild(outline)
' Add page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("CreateTableWithLockedColumns_out.one")
'doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tables()
' Load the document into Aspose.Note.
Dim document As New Document(dataDir & Convert.ToString("Sample1.one"))
' Get a list of table nodes
Dim nodes As IList(Of Table) = document.GetChildNodes(Of Table)()
' Set cell count
Dim cellCount As Integer = 0
For Each table As Table In nodes
' Iterate through table rows
For Each row As TableRow In table
' Get list of TableCell nodes
Dim cellNodes As IList(Of TableCell) = row.GetChildNodes(Of TableCell)()
' Iterate through table cells
For Each cell As TableCell In cellNodes
' Retrieve text
Dim text As String = cell.GetText()
' Print text on the output screen
Console.WriteLine(text)
Next
Next
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tables()
' Load the document into Aspose.Note.
Dim document As New Document(dataDir & Convert.ToString("Sample1.one"))
' Get a list of table nodes
Dim nodes As IList(Of Table) = document.GetChildNodes(Of Table)()
' Set row count
Dim rowCount As Integer = 0
For Each table As Table In nodes
' Iterate through table rows
For Each row As TableRow In table
rowCount += 1
' Retrieve text
Dim text As String = row.GetText()
' Print text on the output screen
Console.WriteLine(text)
Next
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tables()
' Load the document into Aspose.Note.
Dim document As New Document(dataDir & Convert.ToString("Sample1.one"))
' Get a list of table nodes
Dim nodes As IList(Of Table) = document.GetChildNodes(Of Table)()
' Set table count
Dim tblCount As Integer = 0
For Each table As Table In nodes
tblCount += 1
Console.WriteLine("table # " + tblCount.ToString())
' Retrieve text
Dim text As String = table.GetText()
' Print text on the output screen
Console.WriteLine(text)
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Public Shared Function GetOutlineElementWithText(doc As Document, text As String) As OutlineElement
Dim outlineElem As New OutlineElement(doc)
Dim textStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
outlineElem.AppendChild(New RichText(doc) With {
.Text = text,
.DefaultStyle = textStyle
})
Return outlineElem
End Function
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tables()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize TableRow class object
Dim row1 As New TableRow(doc)
' Initialize TableCell class objects
Dim cell11 As New TableCell(doc)
Dim cell12 As New TableCell(doc)
Dim cell13 As New TableCell(doc)
' Append outline elements in the table cell
cell11.AppendChild(GetOutlineElementWithText(doc, "cell_1.1"))
cell12.AppendChild(GetOutlineElementWithText(doc, "cell_1.2"))
cell13.AppendChild(GetOutlineElementWithText(doc, "cell_1.3"))
' Table cells to rows
row1.AppendChild(cell11)
row1.AppendChild(cell12)
row1.AppendChild(cell13)
' Initialize TableRow class object
Dim row2 As New TableRow(doc)
' initialize TableCell class objects
Dim cell21 As New TableCell(doc)
Dim cell22 As New TableCell(doc)
Dim cell23 As New TableCell(doc)
' Append outline elements in the table cell
cell21.AppendChild(GetOutlineElementWithText(doc, "cell_2.1"))
cell22.AppendChild(GetOutlineElementWithText(doc, "cell_2.2"))
cell23.AppendChild(GetOutlineElementWithText(doc, "cell_2.3"))
' Append table cells to rows
row2.AppendChild(cell21)
row2.AppendChild(cell22)
row2.AppendChild(cell23)
' Initialize Table class object and set column widths
Dim table As New Table(doc) With {
.IsBordersVisible = True}
' Append table rows to table
table.AppendChild(row1)
table.AppendChild(row2)
' Initialize Outline object
Dim outline As New Outline(doc)
' Initialize OutlineElement object
Dim outlineElem As New OutlineElement(doc)
' Add table to outline element node
outlineElem.AppendChild(table)
' Add outline element to outline
outline.AppendChild(outlineElem)
' Add outline to page node
page.AppendChild(outline)
' Add page to document node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("InsertTable_out.one")
'doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Aspose.Note.Page(doc)
' Initialize TableRow class object
Dim row1 As New TableRow(doc)
' Initialize TableCell class object and set text content
Dim cell11 As New TableCell(doc)
cell11.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Small text"))
cell11.BackgroundColor = Color.Coral
row1.AppendChild(cell11)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tags()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
' Load an image
Dim image As New Image(doc, dataDir & Convert.ToString("icon.jpg"))
' Insert image in the document node
outlineElem.AppendChild(image)
image.Tags.Add(New NoteTag() With {
.Icon = TagIcon.YellowStar
})
' Add outline element node
outline.AppendChild(outlineElem)
' Add outline node
page.AppendChild(outline)
' Add page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("AddImageNodeWithTag_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tags()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize TableRow class object
Dim row As New TableRow(doc)
' Initialize TableCell class object
Dim cell As New TableCell(doc)
' Insert cell content
cell.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Single cell."))
' Add cell to row node
row.AppendChild(cell)
' Initialize table node
Dim table As New Table(doc) With {
.IsBordersVisible = True
}
' Insert row node in table
table.AppendChild(row)
' Add tag to this table node
table.Tags.Add(New NoteTag() With {
.Icon = TagIcon.QuestionMark
})
Dim outline As New Outline(doc)
Dim outlineElem As New OutlineElement(doc)
' Add table node
outlineElem.AppendChild(table)
' Add outline elements
outline.AppendChild(outlineElem)
page.AppendChild(outline)
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("AddTableNodeWithTag_out.one")
' Save OneNote document
'doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tags()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize OutlineElement class object
Dim outlineElem As New OutlineElement(doc)
Dim textStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
Dim text As New RichText(doc) With {
.Text = "OneNote text.",
.DefaultStyle = textStyle
}
text.Tags.Add(New NoteTag() With {
.Icon = TagIcon.YellowStar
})
' Add text node
outlineElem.AppendChild(text)
' Add outline element node
outline.AppendChild(outlineElem)
' Add outline node
page.AppendChild(outline)
' Add page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("AddTextNodeWithTag_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tags()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("TagFile.one"))
' Get all RichText nodes
Dim nodes As IList(Of RichText) = oneFile.GetChildNodes(Of RichText)()
' Iterate through each node
For Each richText As RichText In nodes
For Each tag In richText.Tags
If TypeOf tag Is NoteTag Then
Dim noteTag As NoteTag = DirectCast(tag, NoteTag)
' Retrieve properties
Console.WriteLine("Completed Time: " + noteTag.CompletedTime.ToString())
Console.WriteLine("Create Time: " + noteTag.CreationTime.ToString())
Console.WriteLine("Font Color: " + noteTag.FontColor.ToString())
Console.WriteLine("Status: " + noteTag.Status.ToString())
Console.WriteLine("Label: " + noteTag.Label)
Console.WriteLine("Icon: " + noteTag.Icon.ToString())
Console.WriteLine("High Light: " + noteTag.Highlight.ToString())
End If
Next
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Tasks()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get all RichText nodes
Dim nodes As IList(Of RichText) = oneFile.GetChildNodes(Of RichText)()
' Iterate through each node
For Each richText As RichText In nodes
For Each tag In richText.Tags
If TypeOf tag Is NoteTask Then
Dim noteTask As NoteTask = DirectCast(tag, NoteTask)
' Retrieve properties
Console.WriteLine("Completed Time: " + noteTask.CompletedTime.ToString())
Console.WriteLine("Create Time: " + noteTask.CreationTime.ToString())
Console.WriteLine("Due Date: " + noteTask.DueDate.ToString())
Console.WriteLine("Status: " + noteTask.Status.ToString())
Console.WriteLine("Task Type: " + noteTask.TaskType.ToString())
Console.WriteLine("Icon: " + noteTask.Icon.ToString())
End If
Next
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize TextStyle class object and set formatting properties
Dim defaultStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
' Initialize OutlineElement class objects and apply bullets
Dim outlineElem1 As New OutlineElement(doc) With {
.NumberList = New NumberList("*", "Arial", 10)
}
' Initialize RichText class object and apply text style
Dim text1 As New RichText(doc) With {
.Text = "First",
.DefaultStyle = defaultStyle
}
outlineElem1.AppendChild(text1)
Dim outlineElem2 As New OutlineElement(doc) With {
.NumberList = New NumberList("*", "Arial", 10)
}
Dim text2 As New RichText(doc) With {
.Text = "Second",
.DefaultStyle = defaultStyle
}
outlineElem2.AppendChild(text2)
Dim outlineElem3 As New OutlineElement(doc) With {
.NumberList = New NumberList("*", "Arial", 10)
}
Dim text3 As New RichText(doc) With {
.Text = "Third",
.DefaultStyle = defaultStyle
}
outlineElem3.AppendChild(text3)
' Add outline elements
outline.AppendChild(outlineElem1)
outline.AppendChild(outlineElem2)
outline.AppendChild(outlineElem3)
' Add Outline node
page.AppendChild(outline)
' Add Page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("ApplyBulletsOnText_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Create an object of the Document class
Dim doc As New Document()
' Initialize Page class object
Dim page As New Page(doc)
' Initialize Outline class object
Dim outline As New Outline(doc)
' Initialize TextStyle class object and set formatting properties
Dim defaultStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
' Initialize OutlineElement class objects and apply numbering
' Numbers in the same outline are automatically incremented.
Dim outlineElem1 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
}
Dim text1 As New RichText(doc) With {
.Text = "First",
.DefaultStyle = defaultStyle
}
outlineElem1.AppendChild(text1)
Dim outlineElem2 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
}
Dim text2 As New RichText(doc) With {
.Text = "Second",
.DefaultStyle = defaultStyle
}
outlineElem2.AppendChild(text2)
Dim outlineElem3 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
}
Dim text3 As New RichText(doc) With {
.Text = "Third",
.DefaultStyle = defaultStyle
}
outlineElem3.AppendChild(text3)
' Add outline elements
outline.AppendChild(outlineElem1)
outline.AppendChild(outlineElem2)
outline.AppendChild(outlineElem3)
' Add Outline node
page.AppendChild(outline)
' Add Page node
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("ApplyNumberingOnText_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Load the document into Aspose.Note.
Dim document As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get a particular RichText node
Dim richTextNodes As IList(Of RichText) = document.GetChildNodes(Of RichText)()
Dim richText As RichText = richTextNodes(0)
For Each style As TextStyle In richText.Styles
' Set font color
style.FontColor = Color.Yellow
' Set highlight color
style.Highlight = Color.Blue
' Set font size
style.FontSize = 20
Next
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
Dim outputPath As String = dataDir & Convert.ToString("CreateTitleMsStyle_out.one")
Dim doc = New Document()
Dim page = New Page(doc)
page.Title = New Title(doc) With {
.TitleText = New RichText(doc) With {
.Text = "Title text.",
.DefaultStyle = TextStyle.DefaultMsOneNoteTitleTextStyle
},
.TitleDate = New RichText(doc) With {
.Text = New DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
.DefaultStyle = TextStyle.DefaultMsOneNoteTitleDateStyle
},
.TitleTime = New RichText(doc) With {
.Text = "12:34",
.DefaultStyle = TextStyle.DefaultMsOneNoteTitleTimeStyle
}
}
doc.AppendChild(page)
doc.Save(outputPath)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Retrieve text
Dim text As String = oneFile.GetText()
' Print text on the output screen
Console.WriteLine(text)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get list of page nodes
Dim nodes As IList(Of Node) = oneFile.GetChildNodes(Of Node)()
If nodes.Count > 0 AndAlso nodes(0).NodeType = NodeType.Page Then
Dim page As Page = DirectCast(nodes(0), Page)
' Retrieve text
Dim text As String = page.GetText()
' Print text on the output screen
Console.WriteLine(text)
End If
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Initialize OneNote document
Dim doc As New Document()
' Initialize OneNote page
Dim page As New Page(doc)
Dim outline As New Outline(doc)
' Apply text style settings
Dim defaultStyle As New TextStyle() With {
.FontColor = Color.Black,
.FontName = "Arial",
.FontSize = 10
}
' Numbers in the same outline are automatically incremented.
Dim outlineElem1 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
}
Dim text1 As New RichText(doc) With {
.Text = "First",
.DefaultStyle = defaultStyle
}
outlineElem1.AppendChild(text1)
'------------------------
Dim outlineElem2 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
}
Dim text2 As New RichText(doc) With {
.Text = "Second",
.DefaultStyle = defaultStyle
}
outlineElem2.AppendChild(text2)
'------------------------
Dim outlineElem3 As New OutlineElement(doc) With {
.NumberList = New NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
}
Dim text3 As New RichText(doc) With {
.Text = "Third",
.DefaultStyle = defaultStyle
}
outlineElem3.AppendChild(text3)
'------------------------
outline.AppendChild(outlineElem1)
outline.AppendChild(outlineElem2)
outline.AppendChild(outlineElem3)
page.AppendChild(outline)
doc.AppendChild(page)
dataDir = dataDir & Convert.ToString("InsertChineseNumberList_out.one")
' Save OneNote document
doc.Save(dataDir)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Text()
Dim replacements As New Dictionary(Of String, String)()
replacements.Add("Some task here", "New Text Here")
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
' Get all RichText nodes
Dim textNodes As IList(Of RichText) = oneFile.GetChildNodes(Of RichText)()
For Each richText As RichText In textNodes
For Each kvp As KeyValuePair(Of String, String) In replacements
If richText IsNot Nothing AndAlso richText.Text.Contains(kvp.Key) Then
' Replace text of a shape
richText.Text = richText.Text.Replace(kvp.Key, kvp.Value)
End If
Next
Next
dataDir = dataDir & Convert.ToString("ReplaceTextOnAllPages_out.pdf")
' Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_Text()
Dim replacements As New Dictionary(Of String, String)()
replacements.Add("voice over", "voice over new text")
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("Aspose.one"))
Dim pageNodes As IList(Of Page) = oneFile.GetChildNodes(Of Page)()
' Get all RichText nodes
Dim textNodes As IList(Of RichText) = pageNodes(0).GetChildNodes(Of RichText)()
For Each richText As RichText In textNodes
For Each kvp As KeyValuePair(Of String, String) In replacements
If richText IsNot Nothing AndAlso richText.Text.Contains(kvp.Key) Then
' Replace text of a shape
richText.Text = richText.Text.Replace(kvp.Key, kvp.Value)
End If
Next
Next
dataDir = dataDir & Convert.ToString("ReplaceTextOnParticularPage_out.pdf")
' Save to any supported file format
oneFile.Save(dataDir, SaveFormat.Pdf)
' For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Note-for-.NET
Dim dataDir As String = RunExamples.GetDataDir_Text()
' Load the document into Aspose.Note.
Dim oneFile As New Document(dataDir & Convert.ToString("ApplyNumberingOnText.one"))
' Retrieve a collection nodes of the outline element
Dim nodes As IList(Of OutlineElement) = oneFile.GetChildNodes(Of OutlineElement)()
' Iterate through each node
For Each node As OutlineElement In nodes
If node.NumberList IsNot Nothing Then
Dim list As NumberList = node.NumberList
' Retrieve font name
Console.WriteLine("Font Name: " + list.Font)
' Retrieve font length
Console.WriteLine("Font Length: " + list.Font.Length.ToString())
' Retrieve font size
Console.WriteLine("Font Size: " + list.FontSize.ToString())
' Retrieve font color
Console.WriteLine("Font Color: " + list.FontColor.ToString())
' Retrieve format
Console.WriteLine("Font format: " + list.Format)
' Check bold
Console.WriteLine("Is bold: " + list.IsBold.ToString())
' Check italic
Console.WriteLine("Is italic: " + list.IsItalic.ToString())
Console.WriteLine()
End If
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment