Class Document
ชื่อพื้นที่: Aspose.Note การประกอบ: Aspose.Note.dll (25.4.0)
แสดงเอกสาร Aspose.Note
public class Document : CompositeNode<page>, INode, ICompositeNode<page>, ICompositeNode, IEnumerable<page>, IEnumerable, INotebookChildNode
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
INode
,
ICompositeNode
อนุญาโตตุลาการ
CompositeNode
Examples
แสดงให้เห็นวิธีการส่งเอกสารไปยังเครื่องพิมพ์โดยใช้คู่สนทนามาตรฐาน Windows พร้อมตัวเลือกเริ่มต้น
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
แสดงวิธีการบันทึกเอกสาร
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
แสดงวิธีการทําเอกสารเข้ารหัส
// 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_NoteBook();
Document document = new Document();
document.Save(dataDir + "CreatingPasswordProtectedDoc_out.one", new OneSaveOptions() { DocumentPassword = "pass" });
แสดงวิธีการบันทึกเอกสารโดยใช้รายการ SaveFormat
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);
แสดงวิธีการบันทึกเอกสารโดยใช้ OneSaveOptions
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());
แสดงวิธีที่จะได้รับจํานวนของหน้าของเอกสาร
// 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.Count();
// Print count on the output screen
Console.WriteLine(count);
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF โดยใช้การตั้งค่าเริ่มต้น
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Save the document as PDF
dataDir = dataDir + "SaveWithDefaultSettings_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
แสดงวิธีการบันทึกเอกสารในรูปแบบ GIF
// 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);
แสดงวิธีการตั้งค่าคุณภาพภาพเมื่อบันทึกเอกสารเป็นภาพในรูปแบบ JPEG
// 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();
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;
}
แสดงวิธีการเชื่อมโยง hyperlink กับภาพ
// 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") { HyperlinkUrl = "http://image.com" };
page.AppendChildLast(image);
document.AppendChildLast(page);
document.Save(dataDir + "Image with Hyperlink_out.one");
แสดงวิธีการบันทึกเอกสารไปยังกระแส
// 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.Seek(0, SeekOrigin.Begin);
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีเพิ่มส่วนใหม่ไปยัง notebook
// 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);
แสดงวิธีการตรวจสอบว่าการโหลดเอกสารจะล้มเหลวเนื่องจากรูปแบบ OneNote 2007 ไม่ได้รับการสนับสนุน
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "OneNote2007.one");
try
{
new Document(fileName);
}
catch (UnsupportedFileFormatException e)
{
if (e.FileFormat == FileFormat.OneNote2007)
{
Console.WriteLine("It looks like the provided file is in OneNote 2007 format that is not supported.");
}
else
throw;
}
แสดงวิธีการกู้คืนรุ่นก่อนหน้านี้ของหน้า
// 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 previousPageVersion = document.GetPageHistory(page).Last();
document.RemoveChild(page);
document.AppendChildLast(previousPageVersion);
document.Save(dataDir + "RollBackRevisions_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));
แสดงวิธีการบันทึกเอกสารในรูปแบบ html ด้วยการจัดเก็บทรัพยากรทั้งหมด(css/fonts/image) ในไฟล์ที่แยกต่างหาก
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
แสดงวิธีการบันทึกเอกสารเข้าสู่การไหลในรูปแบบ html ด้วยการรวมทรัพยากรทั้งหมด (css/fonts/image)
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(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);
แสดงวิธีการตั้งค่าคําอธิบายข้อความสําหรับภาพ
// 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")
{
AlternativeTextTitle = "This is an image's title!",
AlternativeTextDescription = "And this is an image's description!"
};
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir = dataDir + "ImageAlternativeText_out.one";
document.Save(dataDir);
แสดงวิธีที่จะได้รับข้อมูล meta เกี่ยวกับหน้า
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Pages();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
foreach (Page page in oneFile)
{
Console.WriteLine("LastModifiedTime: {0}", page.LastModifiedTime);
Console.WriteLine("CreationTime: {0}", page.CreationTime);
Console.WriteLine("Title: {0}", page.Title);
Console.WriteLine("Level: {0}", page.Level);
Console.WriteLine("Author: {0}", page.Author);
Console.WriteLine();
}
เมื่อหน้า OneNote ระยะยาวจะถูกบันทึกในรูปแบบ 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");
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
// or
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(400);
dataDir = dataDir + "PageSplittUsingKeepPartAndCloneSolidObjectToNextPageAlgorithm_out.pdf";
doc.Save(dataDir);
แสดงวิธีการบันทึกเอกสารในรูปแบบ png
// 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
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_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_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
แสดงวิธีใช้รูปแบบธีมสีดําสําหรับเอกสาร
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<richtext>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));</richtext>
แสดงวิธีการผ่านเนื้อหาของ notebook
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = "Open Notebook.onetoc2";
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);
}
แสดงวิธีรับภาพจากเอกสาร
// 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)));
}
}
}</aspose.note.image></aspose.note.image>
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF
// 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 of first page to be saved
PageIndex = 0,
// Set page count
PageCount = 1,
};
// Save the document as PDF
dataDir = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
แสดงวิธีการบันทึกเอกสารในรูปแบบ 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
{
// Use Jpeg compression
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
// Quality for JPEG compression
JpegQuality = 90
};
dataDir = dataDir + "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
แสดงวิธีการส่งเอกสารไปยังเครื่องพิมพ์โดยใช้คู่สนทนามาตรฐาน Windows พร้อมตัวเลือกที่ระบุ
// 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_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);
}
}
}</attachedfile></attachedfile>
แสดงวิธีที่จะได้รับข้อมูล meta ของภาพ
// 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();
}</aspose.note.image></aspose.note.image>
แสดงวิธีที่จะได้รับประวัติของหน้า
// 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_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);
แสดงวิธีสร้างเอกสารและบันทึกไว้ในรูปแบบ html โดยใช้ตัวเลือกเริ่มต้น
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
แสดงวิธีการตรวจสอบว่าหน้าเป็นหน้าความขัดแย้ง (เช่นมีการเปลี่ยนแปลงที่ OneNote ไม่สามารถเชื่อมต่อได้โดยอัตโนมัติ)
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_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).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
แสดงวิธีเพิ่มไฟล์จากกระแสไปยังเอกสาร
// 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);
using (var stream = File.OpenRead(dataDir + "icon.jpg"))
{
// Initialize AttachedFile class object and also pass its icon path
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, 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);
เมื่อหน้า OneNote ระยะยาวจะถูกบันทึกในรูปแบบ 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");
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);
// Or
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
dataDir = dataDir + "UsingKeepSOlidObjectsAlgorithm_out.pdf";
doc.Save(dataDir);
แสดงวิธีการสร้างเอกสารและบันทึกในรูปแบบ html ช่วงหน้าที่ระบุ
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Initialize OneNote document
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title()
{
TitleText = new RichText() { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText() { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText() { Text = "12:34", ParagraphStyle = textStyle }
};
// Save into HTML format
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
แสดงวิธีสร้างเอกสารที่มีชื่อหน้า
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Create an object of the Document class
Document doc = new Aspose.Note.Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Default style for all text in the document.
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
// Set page title properties
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
// Append Page node in the document
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "CreateDocWithPageTitle_out.one";
doc.Save(dataDir);
แสดงวิธีเพิ่มภาพจากกระแสไปยังเอกสาร
// 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);
OutlineElement outlineElem1 = new OutlineElement(doc);
using (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
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
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);
// Initialize Outline class object and set offset properties
Outline outline = new Outline(doc);
// 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
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);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
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);
// Save OneNote document
dataDir = dataDir + "CreateDocWithSimpleRichText_out.one";
doc.Save(dataDir);
แสดงวิธีการบันทึกเอกสารในรูปแบบที่แตกต่างกัน
// 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");
แสดงวิธีการบันทึกเอกสารในรูปแบบ html ด้วยการจัดเก็บทรัพยากรทั้งหมด(css/fonts/image) โดยใช้โทรกลับที่กําหนดโดยผู้ใช้
// The code below creates 'documentFolder' folder containing document.html, 'css' folder with 'style.css' file, 'images' folder with images and 'fonts' folder with fonts.
// 'style.css' file will contain at the end the following string "/* This line is appended to stream manually by user */"
var savingCallbacks = new UserSavingCallbacks()
{
RootFolder = "documentFolder",
CssFolder = "css",
KeepCssStreamOpened = true,
ImagesFolder = "images",
FontsFolder = "fonts"
};
var options = new HtmlSaveOptions
{
FontFaceTypes = FontFaceType.Ttf,
CssSavingCallback = savingCallbacks,
FontSavingCallback = savingCallbacks,
ImageSavingCallback = savingCallbacks
};
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(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 */");
}
แสดงวิธีการเชื่อมโยง hyperlink ไปยังข้อความ
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tasks();
// Create an object of the Document class
Document doc = new Document();
RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
Outline outline = new Outline()
{
MaxWidth = 200,
MaxHeight = 200,
VerticalOffset = 100,
HorizontalOffset = 100
};
TextStyle textStyleRed = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10,
};
TextStyle textStyleHyperlink = new TextStyle
{
IsHyperlink = true,
HyperlinkAddress = "www.google.com"
};
RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
.Append("This is ", textStyleRed)
.Append("hyperlink", textStyleHyperlink)
.Append(". This text is not a hyperlink.", TextStyle.Default);
OutlineElement outlineElem = new OutlineElement();
outlineElem.AppendChildLast(text);
// Add outline elements
outline.AppendChildLast(outlineElem);
// Initialize Title class object
Title title = new Title() { TitleText = titleText };
// Initialize Page class object
Page page = new Note.Page() { Title = title };
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
แสดงวิธีการเข้าถึงเนื้อหาของเอกสารโดยใช้ผู้เข้าชม
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.AppendLine(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;
this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
/// <summary>
/// Called when processing of a Page node is finished.
/// </summary>
public override void VisitPageEnd(Page page)
{
this.AppendText(string.Empty);
}
/// <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;
}
Constructors
Document()
เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Note.Documentสร้างเอกสาร OneNote สีขาว
public Document()
Document(รั้ว)
เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Note.Documentเปิดเอกสาร OneNote ที่มีอยู่จากไฟล์
public Document(string filePath)
Parameters
filePath
string
เส้นทางไฟล์
Exceptions
UnsupportedFileFormatException
รูปแบบเอกสารไม่ได้รับการยอมรับหรือไม่ได้รับการสนับสนุน
กระดาษดูเหมือนจะถูกกัดกร่อนและไม่สามารถโหลดได้
เอกสารนี้ถูกเข้ารหัสและต้องเปิดรหัสผ่าน แต่คุณให้รหัสผ่านที่ไม่ถูกต้อง
มีปัญหากับเอกสารและควรแจ้งให้ผู้พัฒนา Aspose.Note
มีการยกเว้น input / output
Document(ลวด, LoadOptions)
เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Note.Documentเปิดเอกสาร OneNote ที่มีอยู่จากไฟล์ ช่วยให้คุณระบุตัวเลือกเพิ่มเติมเช่นรหัสผ่านการเข้ารหัสลับ
public Document(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
เส้นทางไฟล์
loadOptions
LoadOptions
ตัวเลือกที่ใช้ในการโหลดเอกสาร สามารถเป็น null
Exceptions
UnsupportedFileFormatException
รูปแบบเอกสารไม่ได้รับการยอมรับหรือไม่ได้รับการสนับสนุน
กระดาษดูเหมือนจะถูกกัดกร่อนและไม่สามารถโหลดได้
เอกสารนี้ถูกเข้ารหัสและต้องเปิดรหัสผ่าน แต่คุณให้รหัสผ่านที่ไม่ถูกต้อง
มีปัญหากับเอกสารและควรแจ้งให้ผู้พัฒนา Aspose.Note
มีการยกเว้น input / output
Document(Stream)
เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Note.Documentเปิดเอกสาร OneNote ที่มีอยู่จาก Stream
public Document(Stream inStream)
Parameters
inStream
Stream
กระแส
Exceptions
UnsupportedFileFormatException
รูปแบบเอกสารไม่ได้รับการยอมรับหรือไม่ได้รับการสนับสนุน
กระดาษดูเหมือนจะถูกกัดกร่อนและไม่สามารถโหลดได้
เอกสารนี้ถูกเข้ารหัสและต้องเปิดรหัสผ่าน แต่คุณให้รหัสผ่านที่ไม่ถูกต้อง
มีปัญหากับเอกสารและควรแจ้งให้ผู้พัฒนา Aspose.Note
มีการยกเว้น input / output
กระแสไม่ได้สนับสนุนการอ่านเป็นศูนย์หรือปิดอยู่แล้ว
Document(แหล่งจ่ายไฟ LoadOptions)
เปิดตัวตัวอย่างใหม่ของคลาส Aspose.Note.Documentเปิดเอกสาร OneNote ที่มีอยู่จาก stream ช่วยให้คุณระบุตัวเลือกเพิ่มเติมเช่นรหัสผ่านการเข้ารหัสลับ
public Document(Stream inStream, LoadOptions loadOptions)
Parameters
inStream
Stream
กระแส
loadOptions
LoadOptions
ตัวเลือกที่ใช้ในการโหลดเอกสาร สามารถเป็น null
Exceptions
UnsupportedFileFormatException
รูปแบบเอกสารไม่ได้รับการยอมรับหรือไม่ได้รับการสนับสนุน
กระดาษดูเหมือนจะถูกกัดกร่อนและไม่สามารถโหลดได้
เอกสารนี้ถูกเข้ารหัสและต้องเปิดรหัสผ่าน แต่คุณให้รหัสผ่านที่ไม่ถูกต้อง
มีปัญหากับเอกสารและควรแจ้งให้ผู้พัฒนา Aspose.Note
มีการยกเว้น input / output
กระแสไม่ได้สนับสนุนการอ่านเป็นศูนย์หรือปิดอยู่แล้ว
Properties
AutomaticLayoutChangesDetectionEnabled
ได้รับหรือตั้งค่าค่าที่แสดงให้เห็นว่า Aspose.Note ทําการตรวจจับการเปลี่ยนแปลงการจัดตั้งโดยอัตโนมัติ หมายเลขค่าเริ่มต้นคือ ‘จริง’
public bool AutomaticLayoutChangesDetectionEnabled { get; set; }
คุณสมบัติมูลค่า
Examples
แสดงวิธีการบันทึกเอกสารในรูปแบบที่แตกต่างกัน
// 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");
Color
ได้รับหรือตั้งค่าสี
public Color Color { get; set; }
คุณสมบัติมูลค่า
CreationTime
รับหรือกําหนดเวลาการสร้าง
public DateTime CreationTime { get; set; }
คุณสมบัติมูลค่า
DisplayName
รับหรือตั้งชื่อแสดงผล
public string DisplayName { get; set; }
คุณสมบัติมูลค่า
FileFormat
รับรูปแบบไฟล์ (OneNote 2010, OneNota Online)
public FileFormat FileFormat { get; }
คุณสมบัติมูลค่า
Examples
แสดงวิธีที่จะได้รับรูปแบบไฟล์ของเอกสาร
// 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;
}
Guid
รับ ID วัตถุที่ไม่ซ้ํากันทั่วโลก
public Guid Guid { get; }
คุณสมบัติมูลค่า
Methods
Accept(DocumentVisitor)
ยินดีต้อนรับผู้เข้าชมของ node
public override void Accept(DocumentVisitor visitor)
Parameters
visitor
DocumentVisitor
วัตถุของชั้นที่มาจาก Aspose.Note.DocumentVisitor
Examples
แสดงวิธีการเข้าถึงเนื้อหาของเอกสารโดยใช้ผู้เข้าชม
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.AppendLine(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;
this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
/// <summary>
/// Called when processing of a Page node is finished.
/// </summary>
public override void VisitPageEnd(Page page)
{
this.AppendText(string.Empty);
}
/// <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;
}
DetectLayoutChanges()
ตรวจสอบการเปลี่ยนแปลงทั้งหมดที่เกิดขึ้นในการจัดตั้งเอกสารตั้งแต่การโทรก่อนหน้านี้ Aspose.Note.Document.DetectLayoutChangesในกรณี Aspose.Note.Document.AutomaticLayoutChangesDetectionEnabled ที่ตั้งค่าเป็นจริง, ใช้โดยอัตโนมัติในช่วงต้นของการส่งออกเอกสาร
public void DetectLayoutChanges()
Examples
แสดงวิธีการบันทึกเอกสารในรูปแบบที่แตกต่างกัน
// 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");
GetPageHistory(Page)
ได้รับ Aspose.Note.PageHistory ซึ่งมีประวัติที่สมบูรณ์สําหรับแต่ละหน้าที่นําเสนอในเอกสาร (ครั้งแรกที่หมายเลข 0)การปรับปรุงหน้าปัจจุบันสามารถเข้าถึงได้เป็น Aspose.Note.PageHistory.Current และมีอยู่แยกจากการเก็บรวบรวมเวอร์ชันประวัติศาสตร์
public PageHistory GetPageHistory(Page page)
Parameters
page
Page
การปรับปรุงปัจจุบันของหน้า
Returns
The Aspose.Note.Pageประวัติศาสตร์
Examples
แสดงวิธีการกู้คืนรุ่นก่อนหน้านี้ของหน้า
// 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 previousPageVersion = document.GetPageHistory(page).Last();
document.RemoveChild(page);
document.AppendChildLast(previousPageVersion);
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;
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");
}
แสดงวิธีการตรวจสอบว่าหน้าเป็นหน้าความขัดแย้ง (เช่นมีการเปลี่ยนแปลงที่ OneNote ไม่สามารถเชื่อมต่อได้โดยอัตโนมัติ)
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);
Import(Stream, PdfImportOptions, ตัวเลือกการไหล)
นําเข้าชุดของหน้าจากเอกสาร PDF ที่ให้
public Document Import(Stream stream, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
Parameters
stream
Stream
กระแสพร้อมเอกสาร PDF
importOptions
PdfImportOptions
รายละเอียดตัวเลือกวิธีการนําเข้าหน้าจากเอกสาร PDF
mergeOptions
MergeOptions
คําอธิบายตัวเลือกวิธีการผสมหน้าที่ให้
Returns
ส่งกลับคําอธิบายไปยังเอกสาร
Import(โลหะ, PdfImportOptions, Mergeoptions)
นําเข้าชุดของหน้าจากเอกสาร PDF ที่ให้
public Document Import(string file, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
Parameters
file
string
ไฟล์ที่มีเอกสาร PDF
importOptions
PdfImportOptions
รายละเอียดตัวเลือกวิธีการนําเข้าหน้าจากเอกสาร PDF
mergeOptions
MergeOptions
คําอธิบายตัวเลือกวิธีการผสมหน้าที่ให้
Returns
ส่งกลับคําอธิบายไปยังเอกสาร
Examples
แสดงวิธีการนําเข้าหน้าทั้งหมดจากชุดเอกสาร PDF หน้าต่อหน้า
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
d.Import(Path.Combine(dataDir, "sampleText.pdf"))
.Import(Path.Combine(dataDir, "sampleImage.pdf"))
.Import(Path.Combine(dataDir, "sampleTable.pdf"));
d.Save(Path.Combine(dataDir, "sample_SimpleMerge.one"));
แสดงวิธีการนําเข้าหน้าทั้งหมดจากชุดเอกสาร PDF ในขณะที่ใส่หน้าจากแต่ละเอกลักษณ์ PDF เป็นเด็กของหน้า OneNote ระดับสูง
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
foreach (var file in new[] { "sampleText.pdf", "sampleImage.pdf", "sampleTable.pdf" })
{
d.AppendChildLast(new Page()).Title = new Title() { TitleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append(file) };
d.Import(Path.Combine(dataDir, file), new PdfImportOptions(), new MergeOptions() { InsertAt = int.MaxValue, InsertAsChild = true });
}
d.Save(Path.Combine(dataDir, "sample_StructuredMerge.one"));
แสดงวิธีการนําเข้าเนื้อหาทั้งหมดจากชุดเอกสาร PDF ในขณะที่เชื่อมต่อหน้าจากแต่ละไฟล์ PDF ไปยังหน้า OneNote เดียว
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
var importOptions = new PdfImportOptions();
var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };
d.Import(Path.Combine(dataDir, "sampleText.pdf"), importOptions, mergeOptions)
.Import(Path.Combine(dataDir, "sampleImage.pdf"), importOptions, mergeOptions)
.Import(Path.Combine(dataDir, "sampleTable.pdf"), importOptions, mergeOptions);
d.Save(Path.Combine(dataDir, "sample_SinglePageMerge.one"));
Import(Stream, HtmlImportOptions, ตัวเลือกการไหล)
นําเข้าชุดของหน้าจากเอกสาร HTML ที่ให้
public Document Import(Stream stream, HtmlImportOptions importOptions, MergeOptions mergeOptions = null)
Parameters
stream
Stream
กระแสที่มีเอกสาร HTML
importOptions
HtmlImportOptions
รายละเอียดตัวเลือกวิธีการนําเข้าหน้าจากเอกสาร HTML
mergeOptions
MergeOptions
คําอธิบายตัวเลือกวิธีการผสมหน้าที่ให้
Returns
ส่งกลับคําอธิบายไปยังเอกสาร
Import(ลวด, HtmlImportOptions, Mergeoption)
นําเข้าชุดของหน้าจากเอกสาร HTML ที่ให้
public Document Import(string file, HtmlImportOptions importOptions, MergeOptions mergeOptions = null)
Parameters
file
string
ไฟล์ที่มีเอกสาร HTML
importOptions
HtmlImportOptions
รายละเอียดตัวเลือกวิธีการนําเข้าหน้าจากเอกสาร HTML
mergeOptions
MergeOptions
คําอธิบายตัวเลือกวิธีการผสมหน้าที่ให้
Returns
ส่งกลับคําอธิบายไปยังเอกสาร
IsEncrypted(Stream, LoadOptions, ออกเอกสาร)
ตรวจสอบว่าเอกสารจากกระแสจะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(Stream stream, LoadOptions options, out Document document)
Parameters
stream
Stream
กระแส
options
LoadOptions
ตัวเลือกโหลด
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(กระแส, string, ออกเอกสาร)
ตรวจสอบว่าเอกสารจากกระแสจะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(Stream stream, string password, out Document document)
Parameters
stream
Stream
กระแส
password
string
รหัสผ่านเพื่อ decrypt a document
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(กระแสออกเอกสาร)
ตรวจสอบว่าเอกสารจากกระแสจะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(Stream stream, out Document document)
Parameters
stream
Stream
กระแส
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(string, LoadOptions, ออกเอกสาร)
ตรวจสอบว่าเอกสารจากไฟล์จะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(string filePath, LoadOptions options, out Document document)
Parameters
filePath
string
เส้นทางไฟล์
options
LoadOptions
ตัวเลือกโหลด
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(string, ภายนอกเอกสาร)
ตรวจสอบว่าเอกสารจากไฟล์จะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(string filePath, out Document document)
Parameters
filePath
string
เส้นทางไฟล์
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ใบมีด, string, out Document)
ตรวจสอบว่าเอกสารจากไฟล์จะเข้ารหัสได้หรือไม่เพื่อตรวจสอบให้แน่ใจว่าเราต้องโหลดเอกสารนี้อย่างสมบูรณ์ ดังนั้นวิธีการนี้สามารถนําไปสู่การรับผิดชอบในการดําเนินการ
public static bool IsEncrypted(string filePath, string password, out Document document)
Parameters
filePath
string
เส้นทางไฟล์
password
string
รหัสผ่านเพื่อ decrypt a document
document
Document
กระดาษที่โหลด
Returns
กลับถูกต้องถ้าเอกสารถูกเข้ารหัสในทางอื่น ๆ ไม่ถูกต้อง
Examples
แสดงวิธีการตรวจสอบว่าเอกสารจะได้รับการป้องกันด้วยรหัสผ่านหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
แสดงวิธีการตรวจสอบว่าเอกสารที่มีรหัสผ่านที่ปกป้องด้วยร密码เฉพาะหรือไม่
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
Merge(หมายเลข , ตัวเลือก Merge)
แปลงชุดของหน้าไปยังเอกสาร
public Document Merge(IEnumerable<page> pages, MergeOptions mergeOptions = null)
Parameters
pages
IEnumerable
<
Page
>
ชุดของหน้า
mergeOptions
MergeOptions
คําอธิบายตัวเลือกวิธีการผสมหน้าที่ให้
Returns
ส่งกลับคําอธิบายไปยังเอกสาร
Examples
แสดงวิธีการนําเข้าหน้าทั้งหมดจากเอกสาร PDF กลุ่มทุก 5 หน้าไปยัง OneNote หน้าเดียว
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };
IEnumerable<page> pages = PdfImporter.Import(Path.Combine(dataDir, "SampleGrouping.pdf"));
while (pages.Any())
{
d.Merge(pages.Take(5), mergeOptions);
pages = pages.Skip(5);
}
d.Save(Path.Combine(dataDir, "sample_CustomMerge.one"));</page>
Print()
พิมพ์เอกสารโดยใช้เครื่องพิมพ์แบบกําหนดเอง
public void Print()
Examples
แสดงให้เห็นวิธีการส่งเอกสารไปยังเครื่องพิมพ์โดยใช้คู่สนทนามาตรฐาน Windows พร้อมตัวเลือกเริ่มต้น
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
แสดงวิธีการส่งเอกสารไปยังเครื่องพิมพ์โดยใช้คู่สนทนามาตรฐาน Windows พร้อมตัวเลือกที่ระบุ
// 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"
});
Print(PrintOptions)
พิมพ์เอกสารโดยใช้เครื่องพิมพ์แบบกําหนดเอง
public void Print(PrintOptions options)
Parameters
options
PrintOptions
ตัวเลือกที่ใช้ในการพิมพ์เอกสาร สามารถเป็น null
Save(รั้ว)
บันทึกเอกสาร OneNote ไปยังไฟล์
public void Save(string fileName)
Parameters
fileName
string
ชื่อเต็มของไฟล์ หากไฟล์ที่มีชื่อเต็มที่ระบุอยู่แล้วไฟล์ปัจจุบันจะถูกเขียนเกินไป
Examples
แสดงวิธีการบันทึกเอกสาร
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน
Save(Stream)
บันทึกเอกสาร OneNote ไปยังการไหล
public void Save(Stream stream)
Parameters
stream
Stream
System.IO.Stream ที่เอกสารจะถูกบันทึกไว้
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน
Save(รั้ว, SaveFormat)
บันทึกเอกสาร OneNote ไปยังไฟล์ในรูปแบบที่ระบุ
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
ชื่อเต็มของไฟล์ หากไฟล์ที่มีชื่อเต็มที่ระบุอยู่แล้วไฟล์ปัจจุบันจะถูกเขียนเกินไป
format
SaveFormat
รูปแบบที่เพื่อบันทึกเอกสาร
Examples
แสดงวิธีการบันทึกเอกสารโดยใช้รายการ SaveFormat
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);
แสดงวิธีการบันทึกเอกสารในรูปแบบ GIF
// 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);
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน
Save(แหล่งจ่ายไฟ, SaveFormat)
บันทึกเอกสาร OneNote ไปยังการไหลในรูปแบบที่ระบุ
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
System.IO.Stream ที่เอกสารจะถูกบันทึกไว้
format
SaveFormat
รูปแบบที่เพื่อบันทึกเอกสาร
Examples
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF โดยใช้การตั้งค่าเริ่มต้น
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Save the document as PDF
dataDir = dataDir + "SaveWithDefaultSettings_out.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");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
// Rewind the stream position back to zero so it is ready for next reader.
dstStream.Seek(0, SeekOrigin.Begin);
แสดงวิธีใช้รูปแบบธีมสีดําสําหรับเอกสาร
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Text();
// Load the document into Aspose.Note.
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<richtext>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));</richtext>
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน
Save(สกรู, SaveOptions)
บันทึกเอกสาร OneNote ไปยังไฟล์โดยใช้ตัวเลือกการบันทึกที่ระบุ
public void Save(string fileName, SaveOptions options)
Parameters
fileName
string
ชื่อเต็มของไฟล์ หากไฟล์ที่มีชื่อเต็มที่ระบุอยู่แล้วไฟล์ปัจจุบันจะถูกเขียนเกินไป
options
SaveOptions
รายละเอียดตัวเลือกวิธีการบันทึกเอกสารในไฟล์
Examples
แสดงวิธีการบันทึกเอกสารโดยใช้ OneSaveOptions
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());
แสดงวิธีการบันทึกเอกสารเป็นภาพในรูปแบบ JPEG โดยใช้ SaveFormat
// 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 + "SaveToJpegImageUsingSaveFormat_out.jpg";
// Save the document.
oneFile.Save(dataDir, SaveFormat.Jpeg);
แสดงวิธีการบันทึกเอกสารเป็นภาพในรูปแบบ Bmp โดยใช้ ImageSaveOptions
// 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 + "SaveToBmpImageUsingImageSaveOptions_out.bmp";
// Save the document.
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF ด้วยการจัดตั้งหน้าจดหมาย
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingLetterPageSettings.pdf");
// Save the document.
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.Letter });
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF ด้วยการจัดตั้งหน้า A4 โดยไม่มีข้อ จํากัด ความสูง
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf");
// Save the document.
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.A4NoHeightLimit });
แสดงวิธีการบันทึกเอกสารเป็นภาพสีเทา
// 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 + "SaveAsGrayscaleImage_out.png";
// Save the document as gif.
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.GrayScale
});
แสดงวิธีการบันทึกเอกสารเป็นภาพในรูปแบบ Tiff โดยใช้การบีบอัด PackBits
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
// Save the document.
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.PackBits
});
แสดงวิธีการบันทึกเอกสารเป็นภาพในรูปแบบ Tiff โดยใช้การบีบอัด Jpeg
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
// Save the document.
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.Jpeg,
Quality = 93
});
แสดงวิธีการบันทึกเอกสารเป็นภาพในรูปแบบ Tiff โดยใช้การบีบอัดเฟ็กซ์ CCITT Group 3
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
// Save the document.
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
ColorMode = ColorMode.BlackAndWhite,
TiffCompression = TiffCompression.Ccitt3
});
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF
// 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 of first page to be saved
PageIndex = 0,
// Set page count
PageCount = 1,
};
// Save the document as PDF
dataDir = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
แสดงวิธีการบันทึกเอกสารในรูปแบบ 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
{
// Use Jpeg compression
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
// Quality for JPEG compression
JpegQuality = 90
};
dataDir = dataDir + "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
แสดงวิธีการบันทึกเอกสารเป็นภาพไบนารีโดยใช้วิธีการ Otsu
// 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 + "SaveToBinaryImageUsingOtsuMethod_out.png";
// Save the document as gif.
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.Otsu,
}
});
แสดงวิธีการบันทึกเอกสารเป็นภาพไบนารีโดยใช้ข้อ จํากัด ที่คงที่
// 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 + "SaveToBinaryImageUsingFixedThreshold_out.png";
// Save the document as gif.
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.FixedThreshold,
BinarizationThreshold = 123
}
});
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน
Save(แหล่งจ่ายไฟ, SaveOptions)
บันทึกเอกสาร OneNote ไปยังการไหลโดยใช้ตัวเลือกการบันทึกที่ระบุ
public void Save(Stream stream, SaveOptions options)
Parameters
stream
Stream
System.IO.Stream ที่เอกสารจะถูกบันทึกไว้
options
SaveOptions
รายละเอียดตัวเลือกวิธีการบันทึกเอกสารในกระแส
Examples
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF โดยใช้ตัวอักษรเริ่มต้นที่ระบุ
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
// Save the document as PDF
dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
oneFile.Save(dataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
});
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF โดยใช้ตัวอักษรเริ่มต้นจากไฟล์
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
// Save the document as PDF
dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
oneFile.Save(dataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
แสดงวิธีการบันทึกเอกสารในรูปแบบ PDF โดยใช้ตัวอักษรที่กําหนดเองจาก Stream
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
// Load the document into Aspose.Note.
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
// Save the document as PDF
dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(dataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
Exceptions
IncorrectDocumentStructureException
โครงสร้างเอกสารละเมิดข้อกําหนด
UnsupportedSaveFormatException
รูปแบบบันทึกที่ต้องการไม่ได้รับการสนับสนุน