Class Document
Tên không gian: Aspose.Note Tổng hợp: Aspose.Note.dll (25.4.0)
Có một tài liệu Aspose.Note
public class Document : CompositeNode<Page>, INode, ICompositeNode<Page>, ICompositeNode, IEnumerable<Page>, IEnumerable, INotebookChildNode
{
}
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
INode
,
ICompositeNode
Thành viên thừa kế
CompositeNode
Examples
Hiển thị cách gửi tài liệu đến một máy in bằng cách sử dụng đối thoại Windows mặc định với các tùy chọn đặt cược.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
Hiển thị cách lưu tài liệu.
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
Hiển thị cách làm cho một tài liệu mã hóa.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
LoadOptions loadOptions = new LoadOptions { DocumentPassword = "password" };
Document doc = new Document(dataDir + "Sample1.one", loadOptions);
Hiển thị cách lưu tài liệu với mã hóa.
string dataDir = RunExamples.GetDataDir_NoteBook();
Document document = new Document();
document.Save(dataDir + "CreatingPasswordProtectedDoc_out.one", new OneSaveOptions { DocumentPassword = "pass" });
Hiển thị cách lưu tài liệu bằng cách sử dụng danh sách 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);
Hiển thị cách lưu tài liệu bằng cách sử dụng 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());
Hiển thị làm thế nào để có được số trang của một tài liệu.
string dataDir = RunExamples.GetDataDir_Pages();
Document oneFile = new Document(dataDir + "Aspose.one");
int count = oneFile.Count();
Console.WriteLine(count);
Hiển thị cách lưu một tài liệu trong định dạng PDF bằng cách sử dụng cài đặt mặc định.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveWithDefaultSettings_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
Hiển thị cách lưu tài liệu trong định dạng gif.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToImageDefaultOptions_out.gif";
oneFile.Save(dataDir, SaveFormat.Gif);
Hiển thị làm thế nào để thiết lập chất lượng hình ảnh khi lưu tài liệu như một bức ảnh trong định dạng JPEG.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Quality = 100 });
Hiển thị làm thế nào để thiết lập độ phân giải hình ảnh khi lưu tài liệu như một bức ảnh.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
int resolution = 220;
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Resolution = resolution });
Hiển thị cách để có được định dạng tệp của một tài liệu.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
switch (document.FileFormat)
{
case FileFormat.OneNote2010:
break;
case FileFormat.OneNoteOnline:
break;
}
Hiển thị cách kết nối một hyperlink với một hình ảnh.
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");
Hiển thị làm thế nào để lưu một tài liệu vào một dòng.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
dstStream.Seek(0, SeekOrigin.Begin);
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách thêm phần mới vào một sổ ghi chép.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));
dataDir += @"\AddChildNode_out.onetoc2";
notebook.Save(dataDir);
Hiển thị cách kiểm tra nếu tải tài liệu thất bại vì định dạng OneNote 2007 không được hỗ trợ.
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;
}
}
Hiển thị cách khôi phục phiên bản trước của một trang.
string dataDir = RunExamples.GetDataDir_Pages();
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");
Hiển thị cách clone một trang.
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone());
cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone(true));
Hiển thị cách để lưu một tài liệu trong định dạng html bằng cách lưu tất cả các tài nguyên (css/fonts/images) vào một tệp riêng biệt.
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);
Hiển thị cách lưu một tài liệu vào một dòng trong định dạng html với sự kết hợp của tất cả các tài nguyên (css/fonts/images).
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);
Hiển thị cách thiết lập mô tả văn bản cho một hình ảnh.
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 += "ImageAlternativeText_out.one";
document.Save(dataDir);
Hiển thị làm thế nào để có được meta thông tin về một trang.
string dataDir = RunExamples.GetDataDir_Pages();
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
foreach (Aspose.Words.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();
}
Khi các trang OneNote dài được lưu trữ trong định dạng pdf, chúng được phân chia qua mỗi trang. mẫu cho thấy cách thiết lập logic chia của các đối tượng nằm trên các khoảng trống của Trang.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(400);
dataDir = dataDir + "PageSplittUsingKeepPartAndCloneSolidObjectToNextPageAlgorithm_out.pdf";
doc.Save(dataDir, pdfSaveOptions);
Hiển thị cách lưu một tài liệu trong định dạng png.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png)
{
PageIndex = 1
};
dataDir += "ConvertSpecificPageToImage_out.png";
oneFile.Save(dataDir, opts);
Hiển thị cách chỉnh sửa lịch sử của trang.
string dataDir = RunExamples.GetDataDir_Pages();
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");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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.");
}
Hiển thị làm thế nào để áp dụng Dark theme style cho một tài liệu.
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<Aspose.Words.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"));
Hiển thị cách thông qua nội dung của một sổ ghi chép.
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)
{
}
else if (notebookChildNode is Notebook)
{
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Hiển thị cách lấy hình ảnh từ một tài liệu.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
IList<aspose.note.Image> nodes = oneFile.GetChildNodes<aspose.note.Image>();
foreach (var image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
bitMap.Save(Path.Combine(dataDir, Path.GetFileName(image.FileName)));
}
}
}
Hiển thị cách lưu một tài liệu trong định dạng PDF.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
PageIndex = 0,
PageCount = 1,
};
dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
Hiển thị cách lưu một tài liệu trong định dạng PDF bằng cách sử dụng cài đặt cụ thể.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
JpegQuality = 90
};
dataDir += "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
Hiển thị cách gửi tài liệu đến một máy in bằng cách sử dụng đối thoại Windows tiêu chuẩn với các tùy chọn được chỉ định.
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"
});
Hiển thị làm thế nào để có được nội dung của một tệp gắn kết.
string dataDir = RunExamples.GetDataDir_Attachments();
Document oneFile = new Document(dataDir + "Sample1.one");
IList<attachedfile> nodes = oneFile.GetChildNodes<attachedfile>();
foreach (AttachedFile file in nodes)
{
using (Stream outputStream = new MemoryStream(file.Bytes))
{
using (System.IO.FileStream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
{
CopyStream(outputStream, fileStream);
}
}
}
Hiển thị cách nhận được thông tin meta của hình ảnh.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
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();
}
Hiển thị cách để có được lịch sử của trang.
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
Console.WriteLine("LastModifiedTime: {0}", pageRevision.LastModifiedTime);
Console.WriteLine("CreationTime: {0}", pageRevision.CreationTime);
Console.WriteLine("Title: {0}", pageRevision.Title);
Console.WriteLine("Level: {0}", pageRevision.Level);
Console.WriteLine("Author: {0}", pageRevision.Author);
Console.WriteLine();
}
Hiển thị cách thêm tệp vào một tài liệu bằng cách sử dụng filepath.
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");
outlineElem.AppendChildLast(attachedFile);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileByPath_out.one";
doc.Save(dataDir);
Hiển thị cách tạo một tài liệu và lưu nó trong định dạng html bằng cách sử dụng tùy chọn mặc định.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
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 }
};
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
Hiển thị cách kiểm tra xem một trang có phải là trang xung đột (ví dụ, nó có những thay đổi mà OneNote không thể tự động kết hợp).
string dataDir = RunExamples.GetDataDir_Pages();
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);
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
Hiển thị cách thêm một hình ảnh từ tệp vào một tài liệu với các thuộc tính được xác định bởi người dùng.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = HorizontalAlignment.Right
};
page.AppendChildLast(image);
Hiển thị cách thêm một tệp từ một dòng vào một tài liệu.
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
using (var stream = File.OpenRead(dataDir + "icon.jpg"))
{
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);
outlineElem.AppendChildLast(attachedFile);
}
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileAndSetIcon_out.one";
doc.Save(dataDir);
Khi các trang dài của OneNote được lưu trữ trong định dạng pdf, chúng được chia thành mỗi trang. ví dụ này cho thấy cách thiết lập logic chia của các đối tượng nằm trên các khoảng trống của trang .
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new AlwaysSplitObjectsAlgorithm();
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm();
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
float heightLimitOfClonedPart = 500;
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(heightLimitOfClonedPart);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
dataDir = dataDir + "UsingKeepSOlidObjectsAlgorithm_out.pdf";
doc.Save(dataDir, pdfSaveOptions);
Hiển thị cách tạo một tài liệu và lưu trong định dạng html một loạt các trang cụ thể.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
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
}
};
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
Hiển thị làm thế nào để tạo một tài liệu với trang có tiêu đề.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
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 += "CreateDocWithPageTitle_out.one";
doc.Save(dataDir);
Hiển thị làm thế nào để thêm một hình ảnh từ dòng vào một tài liệu.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
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"))
{
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Hiển thị cách thêm hình ảnh từ tệp vào tài liệu.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Alignment = HorizontalAlignment.Right
};
outlineElem.AppendChildLast(image);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
Hiển thị cách tạo một tài liệu với một văn bản.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page(doc);
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 = "Hello OneNote text!",
ParagraphStyle = textStyle
};
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "CreateDocWithSimpleRichText_out.one";
doc.Save(dataDir);
Hiển thị cách lưu một tài liệu trong các định dạng khác nhau.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
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);
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");
Hiển thị cách lưu một tài liệu trong định dạng html với lưu tất cả các tài nguyên (css/fonts/images) bằng cách sử dụng callbacks được xác định bởi người dùng.
using System.IO;
using Aspose.Words;
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 */");
}
Hiển thị cách kết nối một hyperlink với một văn bản.
string dataDir = RunExamples.GetDataDir_Tasks();
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()
.Append("This is ", textStyleRed)
.Append("hyperlink", textStyleHyperlink)
.Append(". This text is not a hyperlink.", TextStyle.Default);
OutlineElement outlineElem = new OutlineElement();
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
Title title = new Title() { TitleText = titleText };
Page page = new Note.Page() { Title = title };
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
Hiển thị cách truy cập nội dung của một tài liệu bằng cách sử dụng khách.
public static void Run()
{
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
doc.Accept(myConverter);
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
NodeCount = 0;
IsSkipText = false;
Builder = new StringBuilder();
}
public string GetText()
{
return Builder.ToString();
}
private void AppendText(string text)
{
if (!IsSkipText)
{
Builder.AppendLine(text);
}
}
public override void VisitRichTextStart(RichText run)
{
++NodeCount;
AppendText(run.Text);
}
public override void VisitDocumentStart(Document document)
{
++NodeCount;
}
public override void VisitPageStart(Page page)
{
++NodeCount;
AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
public override void VisitPageEnd(Page page)
{
AppendText(string.Empty);
}
public override void VisitTitleStart(Title title)
{
++NodeCount;
}
public override void VisitImageStart(Image image)
{
++NodeCount;
}
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++NodeCount;
}
public override void VisitOutlineStart(Outline outline)
{
++NodeCount;
}
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++NodeCount;
}
public Int32 NodeCount
{
get { return this.nodeCount; }
}
private readonly StringBuilder Builder;
private bool IsSkipText;
private int nodeCount;
}
Constructors
Tài liệu ( )
Bắt đầu một trường hợp mới của lớp Aspose.Note.Document.Tạo một tài liệu OneNote trắng.
public Document()
{
}
Tài liệu (string )
Bắt đầu một trường hợp mới của lớp Aspose.Note.Document.Mở một tài liệu OneNote hiện có từ một tệp.
public Document(string filePath)
{
}
Parameters
filePath
string
đường file.
Exceptions
UnsupportedFileFormatException
Định dạng tài liệu không được công nhận hoặc không được hỗ trợ.
Tài liệu dường như bị phá hủy và không thể tải lên.
Tài liệu được mã hóa và yêu cầu mật khẩu để mở, nhưng bạn đã cung cấp mật khẩu không chính xác.
Có một vấn đề với tài liệu và nó nên được báo cáo cho các nhà phát triển Aspose.Note.
Có một ngoại lệ input / output.
Tài liệu (string, LoadOptions)
Bắt đầu một trường hợp mới của lớp Aspose.Note.Document.Mở một tài liệu OneNote hiện có từ một tệp. cho phép xác định các tùy chọn bổ sung như mật khẩu mã hóa.
public Document(string filePath, LoadOptions loadOptions)
{
}
Parameters
filePath
string
đường file.
loadOptions
LoadOptions
Các tùy chọn được sử dụng để tải một tài liệu. có thể là không.
Exceptions
UnsupportedFileFormatException
Định dạng tài liệu không được công nhận hoặc không được hỗ trợ.
Tài liệu dường như bị phá hủy và không thể tải lên.
Tài liệu được mã hóa và yêu cầu mật khẩu để mở, nhưng bạn đã cung cấp mật khẩu không chính xác.
Có một vấn đề với tài liệu và nó nên được báo cáo cho các nhà phát triển Aspose.Note.
Có một ngoại lệ input / output.
Tài liệu ( Stream )
Bắt đầu một trường hợp mới của lớp Aspose.Note.Document.Mở một tài liệu OneNote hiện có từ một dòng.
public Document(Stream inStream)
{
}
Parameters
inStream
Stream
dòng chảy
Exceptions
UnsupportedFileFormatException
Định dạng tài liệu không được công nhận hoặc không được hỗ trợ.
Tài liệu dường như bị phá hủy và không thể tải lên.
Tài liệu được mã hóa và yêu cầu mật khẩu để mở, nhưng bạn đã cung cấp mật khẩu không chính xác.
Có một vấn đề với tài liệu và nó nên được báo cáo cho các nhà phát triển Aspose.Note.
Có một ngoại lệ input / output.
Stream không hỗ trợ đọc, không có hoặc đã đóng cửa.
Tài liệu (Stream, LoadOptions)
Bắt đầu một trường hợp mới của lớp Aspose.Note.Document.Mở tài liệu OneNote hiện có từ một dòng. cho phép xác định các tùy chọn bổ sung như mật khẩu mã hóa.
public Document(Stream inStream, LoadOptions loadOptions)
{
}
Parameters
inStream
Stream
dòng chảy
loadOptions
LoadOptions
Các tùy chọn được sử dụng để tải một tài liệu. có thể là không.
Exceptions
UnsupportedFileFormatException
Định dạng tài liệu không được công nhận hoặc không được hỗ trợ.
Tài liệu dường như bị phá hủy và không thể tải lên.
Tài liệu được mã hóa và yêu cầu mật khẩu để mở, nhưng bạn đã cung cấp mật khẩu không chính xác.
Có một vấn đề với tài liệu và nó nên được báo cáo cho các nhà phát triển Aspose.Note.
Có một ngoại lệ input / output.
Stream không hỗ trợ đọc, không có hoặc đã đóng cửa.
Properties
AutomaticLayoutChangesDetectionEnabled
Nhận hoặc đặt một giá trị cho biết Aspose.Note có thực hiện việc phát hiện các thay đổi bố trí tự động hay không.Giá mặc định là ’thực tế'.
public bool AutomaticLayoutChangesDetectionEnabled
{
get;
set;
}
Giá trị bất động sản
Examples
Hiển thị cách lưu một tài liệu trong các định dạng khác nhau.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
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);
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
Nhận hoặc đặt màu sắc.
public Color Color
{
get { return this.Color; }
set { this.Color = value; }
}
Giá trị bất động sản
CreationTime
Nhận hoặc đặt thời gian sáng tạo.
public DateTime CreationTime
{
get;
set;
}
Giá trị bất động sản
DisplayName
Nhận hoặc đặt tên hiển thị.
public string DisplayName
{
get;
set;
}
Giá trị bất động sản
FileFormat
Nhận định dạng tệp (OneNote 2010, OneNota Online).
public FileFormat FileFormat
{
get;
}
Giá trị bất động sản
Examples
Hiển thị cách để có được định dạng tệp của một tài liệu.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
switch (document.FileFormat)
{
case Aspose.Words.FileFormat.OneNote2010:
break;
case Aspose.Words.FileFormat.OneNoteOnline:
break;
}
Guid
Nhận ID độc đáo toàn cầu của đối tượng.
public Guid Guid
{
get;
}
Giá trị bất động sản
Methods
Nhận (DocumentVisitor)
chấp nhận khách truy cập của nút.
public override void Accept(DocumentVisitor visitor)
{
}
Parameters
visitor
DocumentVisitor
Đối tượng của một lớp được lấy từ Aspose.Note.DocumentVisitor.
Examples
Hiển thị cách truy cập nội dung của một tài liệu bằng cách sử dụng khách.
public static void Run()
{
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
doc.Accept(myConverter);
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
nodecount = 0;
mIsSkipText = false;
mBuilder = new StringBuilder();
}
public string GetText()
{
return mBuilder.ToString();
}
private void AppendText(string text)
{
if (!mIsSkipText)
{
mBuilder.AppendLine(text);
}
}
public override void VisitRichTextStart(RichText run)
{
++nodecount;
AppendText(run.Text);
}
public override void VisitDocumentStart(Document document)
{
++nodecount;
}
public override void VisitPageStart(Page page)
{
++nodecount;
this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
public override void VisitPageEnd(Page page)
{
this.AppendText(string.Empty);
}
public override void VisitTitleStart(Title title)
{
++nodecount;
}
public override void VisitImageStart(Image image)
{
++nodecount;
}
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++nodecount;
}
public override void VisitOutlineStart(Outline outline)
{
++nodecount;
}
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++nodecount;
}
public Int32 NodeCount
{
get { return this.nodecount; }
}
private readonly StringBuilder mBuilder;
private bool mIsSkipText;
private Int32 nodecount;
}
Thay đổi phát hiện()
Phát hiện tất cả các thay đổi được thực hiện trong bố trí tài liệu kể từ cuộc gọi trước Aspose.Note.Document.DetectLayoutChanges.Trong trường hợp Aspose.Note.Document.AutomaticLayoutChangesDetectionEnabled được thiết lập để xác thực, được sử dụng tự động vào đầu xuất tài liệu.
public void DetectLayoutChanges()
{
}
Examples
Hiển thị cách lưu một tài liệu trong các định dạng khác nhau.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
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);
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");
Giới thiệu về GetPageHistory(page)
Nhận Aspose.Note.PageHistory chứa lịch sử đầy đủ cho mỗi trang được trình bày trong một tài liệu (tạm dịch là đầu tiên ở chỉ số 0).Bản sửa đổi trang hiện tại có thể được truy cập dưới dạng Aspose.Note.PageHistory.Current và chứa riêng biệt từ bộ sưu tập các phiên bản lịch sử.
public PageHistory GetPageHistory(Page page)
{
}
I have reformatted the given C# code by:
- Properly indented the method body and comments.
- Added a single space between the opening brace, method name, and opening parenthesis.
- Added a single line between the method signature and its implementation.
- Added two spaces for each level of nesting within the method body for improved readability.
Parameters
page
Page
Bản sửa đổi hiện tại của một trang.
Returns
Các Aspose.Note.PageHistory.
Examples
Hiển thị cách khôi phục phiên bản trước của một trang.
string dataDir = RunExamples.GetDataDir_Pages();
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");
Hiển thị cách chỉnh sửa lịch sử của trang.
string dataDir = RunExamples.GetDataDir_Pages();
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");
}
Hiển thị cách kiểm tra xem một trang có phải là trang xung đột (ví dụ, nó có những thay đổi mà OneNote không thể tự động kết hợp).
string dataDir = RunExamples.GetDataDir_Pages();
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: ", i);
Console.Write("{1}, ", historyPage.PageContentRevisionSummary.AuthorMostRecent);
Console.WriteLine("{2:dd.MM.yyyy hh.mm.ss}", historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
Xuất khẩu (Stream, PdfImportOptions, MergeOption)
Import một tập hợp các trang từ tài liệu PDF được cung cấp.
public Document Import(Stream stream, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
{
}
Parameters
stream
Stream
Một dòng với tài liệu PDF.
importOptions
PdfImportOptions
Cài đặt các tùy chọn làm thế nào để nhập trang từ tài liệu PDF.
mergeOptions
MergeOptions
Cụ thể các tùy chọn làm thế nào để kết hợp các trang được cung cấp.
Returns
Quay lại đề cập đến tài liệu.
Import(string, PdfImportOptions, MergeOption)
Import một tập hợp các trang từ tài liệu PDF được cung cấp.
public Document Import(string file, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
{
}
Parameters
file
string
Một tập tin với tài liệu PDF.
importOptions
PdfImportOptions
Cài đặt các tùy chọn làm thế nào để nhập trang từ tài liệu PDF.
mergeOptions
MergeOptions
Cụ thể các tùy chọn làm thế nào để kết hợp các trang được cung cấp.
Returns
Quay lại đề cập đến tài liệu.
Examples
Hiển thị làm thế nào để nhập tất cả các trang từ một tập hợp các tài liệu PDF trang theo trang.
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"));
Hiển thị làm thế nào để nhập tất cả các trang từ một tập hợp tài liệu PDF trong khi nhập các Trang từ mỗi văn bản PDF như trẻ em của một trang OneNote cấp cao.
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
.SetTitleText(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"));
Hiển thị làm thế nào để nhập tất cả nội dung từ một bộ tài liệu PDF trong khi kết hợp các trang từ mỗi tài khoản PDF vào một trang OneNote duy nhất.
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"));
Xuất khẩu (Stream, HtmlImportOptions, MergeOption)
Import một tập hợp các trang từ tài liệu HTML được cung cấp.
public Document Import(
Stream stream,
HtmlImportOptions importOptions,
MergeOptions mergeOptions = null)
{
}
Parameters
stream
Stream
Một dòng với tài liệu HTML.
importOptions
HtmlImportOptions
Cài đặt các tùy chọn làm thế nào để nhập trang từ tài liệu HTML.
mergeOptions
MergeOptions
Cụ thể các tùy chọn làm thế nào để kết hợp các trang được cung cấp.
Returns
Quay lại đề cập đến tài liệu.
Import(string, HtmlImportOptions, MergeOption)
Import một tập hợp các trang từ tài liệu HTML được cung cấp.
public Document Import(string file, HtmlImportOptions importOptions, MergeOptions mergeOptions = null)
{
}
Parameters
file
string
Một tập tin với tài liệu HTML.
importOptions
HtmlImportOptions
Cài đặt các tùy chọn làm thế nào để nhập trang từ tài liệu HTML.
mergeOptions
MergeOptions
Cụ thể các tùy chọn làm thế nào để kết hợp các trang được cung cấp.
Returns
Quay lại đề cập đến tài liệu.
IsEncrypted(Stream, LoadOptions, Out Document)
Kiểm tra xem một tài liệu từ một dòng có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(Stream stream, LoadOptions options, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream, options);
return document.IsEncrypted;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return false;
}
Parameters
stream
Stream
dòng chảy
options
LoadOptions
Các tùy chọn tải.
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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(Stream, string, out Document)
Kiểm tra xem một tài liệu từ một dòng có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(Stream stream, string password, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream, Aspose.Words.FileFormatUtil.DetectEncryptionType(stream), password);
}
catch (Exception ex)
{
return false;
}
return true;
}
Parameters
stream
Stream
dòng chảy
password
string
mật khẩu để xóa tài liệu.
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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 (Stream, Out Document) (Nhạc Chuông)
Kiểm tra xem một tài liệu từ một dòng có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(Stream stream, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream);
return document.EncryptionSettings != null && document.EncryptionSettings.IsEncrypted;
}
catch
{
document = null;
throw;
}
}
Parameters
stream
Stream
dòng chảy
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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, Out Document)
Kiểm tra xem một tài liệu từ một tệp có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(string filePath, LoadOptions options, out Document document)
{
document = null;
try
{
using (var doc = new Document(File.OpenRead(filePath), options))
{
document = doc;
return false;
}
}
catch (InvalidPasswordException ex)
{
document = null;
return true;
}
}
Parameters
filePath
string
đường file.
options
LoadOptions
Các tùy chọn tải.
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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 Tài liệu)
Kiểm tra xem một tài liệu từ một tệp có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(string filePath, out Document document)
{
document = null;
try
{
Aspose.Words.Document asposeDoc = new Aspose.Words.Document(filePath);
document = asposeDoc;
return asposeDoc.ProtectionSettings.EncryptionInfo != null;
}
catch (Exception ex)
{
}
document = null;
return false;
}
Parameters
filePath
string
đường file.
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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, string, out Document)
Kiểm tra xem một tài liệu từ một tệp có được mã hóa hay không.Để kiểm tra nó, chúng ta cần tải đầy đủ tài liệu này. Vì vậy, phương pháp này có thể dẫn đến hình phạt hiệu suất.
public static bool IsEncrypted(string filePath, string password, out Document document)
{
}
Parameters
filePath
string
đường file.
password
string
mật khẩu để xóa tài liệu.
document
Document
Tài liệu tải.
Returns
Trả lại đúng nếu tài liệu được mã hóa nếu không giả.
Examples
Hiển thị làm thế nào để kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu.
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.");
}
Hiển thị cách kiểm tra nếu một tài liệu được bảo vệ bằng mật khẩu cụ thể.
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.");
}
Lời bài hát: Unnumerable, MergeOptions)
Nhập một số trang vào tài liệu.
public Document Merge(IEnumerable<Page> pages, MergeOptions mergeOptions = null)
{
}
Parameters
pages
IEnumerable
<
Page
>
Một loạt các trang.
mergeOptions
MergeOptions
Cụ thể các tùy chọn làm thế nào để kết hợp các trang được cung cấp.
Returns
Quay lại đề cập đến tài liệu.
Examples
Hiển thị cách nhập tất cả các trang từ tài liệu PDF nhóm mỗi 5 trang vào một trang OneNote duy nhất.
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"));
Tác giả ( )
In tài liệu bằng cách sử dụng máy in mặc định.
public void Print()
{
}
Examples
Hiển thị cách gửi tài liệu đến một máy in bằng cách sử dụng đối thoại Windows mặc định với các tùy chọn đặt cược.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
Hiển thị cách gửi tài liệu đến một máy in bằng cách sử dụng đối thoại Windows tiêu chuẩn với các tùy chọn được chỉ định.
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"
});
Tùy chọn (Print Options)
In tài liệu bằng cách sử dụng máy in mặc định.
public void Print(PrintOptions options)
{
}
Parameters
options
PrintOptions
Các tùy chọn được sử dụng để in một tài liệu. có thể là không.
Tiết kiệm ( String )
Lưu tài liệu OneNote vào một tệp.
public void Save(string fileName)
{
}
Parameters
fileName
string
Nếu một tệp có tên đầy đủ đã tồn tại, file hiện có sẽ được viết quá.
Examples
Hiển thị cách lưu tài liệu.
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
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.
Cung cấp ( Stream )
Tiết kiệm tài liệu OneNote cho một dòng.
public void Save(Stream stream)
{
}
Parameters
stream
Stream
Hệ thống.IO.Stream nơi tài liệu sẽ được lưu.
Exceptions
IncorrectDocumentStructureException
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.
Lưu trữ (string, SaveFormat)
Lưu tài liệu OneNote vào một tệp trong định dạng cụ thể.
public void Save(string fileName, Aspose.Words.SaveFormat format)
{
}
Parameters
fileName
string
Nếu một tệp có tên đầy đủ đã tồn tại, file hiện có sẽ được viết quá.
format
SaveFormat
Định dạng trong đó để lưu tài liệu.
Examples
Hiển thị cách lưu tài liệu bằng cách sử dụng danh sách 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);
Hiển thị cách lưu tài liệu trong định dạng gif.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToImageDefaultOptions_out.gif";
oneFile.Save(dataDir, SaveFormat.Gif);
Exceptions
IncorrectDocumentStructureException
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.
Tải về (SaveFormat, Stream)
Lưu tài liệu OneNote vào một dòng trong định dạng cụ thể.
public void Save(Stream stream, SaveFormat format)
{
}
Parameters
stream
Stream
Hệ thống.IO.Stream nơi tài liệu sẽ được lưu.
format
SaveFormat
Định dạng trong đó để lưu tài liệu.
Examples
Hiển thị cách lưu một tài liệu trong định dạng PDF bằng cách sử dụng cài đặt mặc định.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
string dataDirWithFileName = dataDir + "SaveWithDefaultSettings_out.pdf";
oneFile.Save(dataDirWithFileName, SaveFormat.Pdf);
Hiển thị làm thế nào để lưu một tài liệu vào một dòng.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
dstStream.Seek(0, SeekOrigin.Begin);
Hiển thị làm thế nào để áp dụng Dark theme style cho một tài liệu.
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<Aspose.Words.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"));
Exceptions
IncorrectDocumentStructureException
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.
Tiết kiệm (string, SaveOptions)
Lưu tài liệu OneNote vào một tệp bằng cách sử dụng các tùy chọn lưu được chỉ định.
public void Save(string fileName, SaveOptions options)
{
}
Parameters
fileName
string
Nếu một tệp có tên đầy đủ đã tồn tại, file hiện có sẽ được viết quá.
options
SaveOptions
Cài đặt các tùy chọn làm thế nào tài liệu được lưu trong tệp.
Examples
Hiển thị cách lưu tài liệu bằng cách sử dụng 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());
Hiển thị cách lưu một tài liệu như một hình ảnh trong định dạng JPEG bằng cách sử dụng SaveFormat.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToJpegImageUsingSaveFormat_out.jpg";
oneFile.Save(dataDir, SaveFormat.Jpeg);
Hiển thị cách lưu một tài liệu như một hình ảnh trong định dạng Bmp bằng cách sử dụng ImageSaveOptions.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBmpImageUsingImageSaveOptions_out.bmp";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));
Hiển thị cách lưu một tài liệu trong định dạng PDF với bố trí trang Thư.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingLetterPageSettings.pdf");
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.Letter });
Hiển thị cách lưu một tài liệu trong định dạng PDF với bố trí trang A4 mà không có giới hạn chiều cao.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf");
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.A4NoHeightLimit });
Hiển thị cách lưu một tài liệu như một hình ảnh màu xám.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveAsGrayscaleImage_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.GrayScale
});
Hiển thị cách lưu một tài liệu như một hình ảnh trong định dạng Tiff bằng cách sử dụng nén PackBits.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.PackBits
});
Hiển thị cách lưu một tài liệu như một hình ảnh trong định dạng Tiff bằng cách sử dụng Jpeg.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.Jpeg,
Quality = 93
});
Hiển thị cách lưu một tài liệu như một hình ảnh trong định dạng Tiff bằng cách sử dụng CCITT Group 3 fax compression.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
ColorMode = ColorMode.BlackAndWhite,
TiffCompression = TiffCompression.Ccitt3
});
Hiển thị cách lưu một tài liệu trong định dạng PDF.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
PageIndex = 0,
PageCount = 1,
};
dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
Hiển thị cách lưu một tài liệu trong định dạng PDF bằng cách sử dụng cài đặt cụ thể.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions
{
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
JpegQuality = 90
};
dataDir += "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
Hiển thị cách lưu một tài liệu như một hình ảnh nhị phân bằng cách sử dụng phương pháp của Otsu.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBinaryImageUsingOtsuMethod_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.Otsu,
}
});
Hiển thị cách lưu một tài liệu như một hình ảnh nhị phân bằng cách sử dụng giới hạn cố định.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.FixedThreshold,
BinarizationThreshold = 123
}
});
Exceptions
IncorrectDocumentStructureException
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.
Save (tạm dịch: Stream, SaveOptions)
Lưu tài liệu OneNote cho một dòng bằng cách sử dụng các tùy chọn lưu được chỉ định.
public void Save(Stream stream, SaveOptions options)
{
}
Parameters
stream
Stream
Hệ thống.IO.Stream nơi tài liệu sẽ được lưu.
options
SaveOptions
Cài đặt các tùy chọn làm thế nào tài liệu được lưu trong dòng.
Examples
Hiển thị cách lưu một tài liệu trong định dạng pdf bằng cách sử dụng phông chữ mặc định cụ thể.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string dataDirWithOutputPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
oneFile.Save(dataDirWithOutputPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
});
Hiển thị cách lưu một tài liệu trong định dạng pdf bằng cách sử dụng phông chữ mặc định từ một tệp.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string outputFile = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
oneFile.Save(outputFile, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
Hiển thị cách lưu một tài liệu trong định dạng pdf bằng cách sử dụng phông chữ mặc định từ một dòng.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string fullDataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(fullDataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
Exceptions
IncorrectDocumentStructureException
cấu trúc tài liệu vi phạm các thông số kỹ thuật.
UnsupportedSaveFormatException
Định dạng lưu yêu cầu không được hỗ trợ.