SaveOptions.PageIndex
内容
[
隐藏
]SaveOptions.PageIndex property
获取或设置要保存的第一页的索引。默认值为 0。
public int PageIndex { get; set; }
示例
展示如何以 PNG 格式保存文档。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 将文档加载到 Aspose.Note 中。
Document oneFile = new Document(dataDir + "Aspose.one");
// 初始化 ImageSaveOptions 对象
ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png)
{
// 设置页面索引
PageIndex = 1
};
dataDir = dataDir + "ConvertSpecificPageToImage_out.png";
// 将文档保存为 PNG。
oneFile.Save(dataDir, opts);
展示如何以 PDF 格式保存文档。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 将文档加载到 Aspose.Note 中。
Document oneFile = new Document(dataDir + "Aspose.one");
// 初始化 PdfSaveOptions 对象
PdfSaveOptions opts = new PdfSaveOptions
{
// 设置要保存的第一页的页面索引
PageIndex = 0,
// 设置页面数量
PageCount = 1,
};
// 将文档保存为 PDF
dataDir = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
展示如何使用特定设置以 PDF 格式保存文档。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 将文档加载到 Aspose.Note 中。
Document doc = new Document(dataDir + "Aspose.one");
// 初始化 PdfSaveOptions 对象
PdfSaveOptions opts = new PdfSaveOptions
{
// 使用 Jpeg 压缩
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
// JPEG 压缩质量
JpegQuality = 90
};
dataDir = dataDir + "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
展示如何创建文档并在指定页面范围内以 HTML 格式保存。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 初始化 OneNote 文档
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 }
};
// 保存为 HTML 格式
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
展示如何创建带格式化富文本的文档。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// 创建 Document 类的对象
Document doc = new Document();
// 初始化 Page 类对象
Page page = new Page();
// 初始化 Title 类对象
Title title = new Title();
// 初始化 TextStyle 类对象并设置格式属性
ParagraphStyle defaultTextStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText titleText = new RichText() { ParagraphStyle = defaultTextStyle }.Append("Title!");
Outline outline = new Outline()
{
VerticalOffset = 100,
HorizontalOffset = 100
};
OutlineElement outlineElem = new OutlineElement();
TextStyle textStyleForHelloWord = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10,
};
TextStyle textStyleForOneNoteWord = new TextStyle
{
FontColor = Color.Green,
FontName = "Calibri",
FontSize = 10,
IsItalic = true,
};
TextStyle textStyleForTextWord = new TextStyle
{
FontColor = Color.Blue,
FontName = "Arial",
FontSize = 15,
IsBold = true,
IsItalic = true,
};
RichText text = new RichText() { ParagraphStyle = defaultTextStyle }
.Append("Hello", textStyleForHelloWord)
.Append(" OneNote", textStyleForOneNoteWord)
.Append(" text", textStyleForTextWord)
.Append("!", TextStyle.Default);
title.TitleText = titleText;
// 设置页面标题
page.Title = title;
// 添加 RichText 节点
outlineElem.AppendChildLast(text);
// 添加 OutlineElement 节点
outline.AppendChildLast(outlineElem);
// 添加 Outline 节点
page.AppendChildLast(outline);
// 添加 Page 节点
doc.AppendChildLast(page);
// 保存 OneNote 文档
dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
doc.Save(dataDir);
另请参阅
- class SaveOptions
- namespace Aspose.Note.Saving
- assembly Aspose.Note