Odd

PageSet.Odd property

获取文档所有奇数页按原始顺序排列的集合。

public static PageSet Odd { get; }

评论

奇数页具有偶数索引,因为页面索引是从零开始的。

例子

显示如何从文档中导出奇数页。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

for (int i = 0; i < 5; i++)
{
    builder.Writeln($"Page {i + 1} ({(i % 2 == 0 ? "odd" : "even")})");
    if (i < 4)
        builder.InsertBreak(BreakType.PageBreak);
}

// 创建一个“PdfSaveOptions”对象,我们可以将其传递给文档的“Save”方法
// 修改该方法将文档转换为 .PDF 的方式。
PdfSaveOptions options = new PdfSaveOptions();

// 下面是三个 PageSet 属性,我们可以用它们来从中筛选出一组页面
// 根据页码的奇偶性将我们的文档保存在输出 PDF 文档中。
// 1 - 仅保存偶数页:
options.PageSet = PageSet.Even;

doc.Save(ArtifactsDir + "PdfSaveOptions.ExportPageSet.Even.pdf", options);

// 2 - 仅保存奇数页:
options.PageSet = PageSet.Odd;

doc.Save(ArtifactsDir + "PdfSaveOptions.ExportPageSet.Odd.pdf", options);

// 3 - 保存每一页:
options.PageSet = PageSet.All;

doc.Save(ArtifactsDir + "PdfSaveOptions.ExportPageSet.All.pdf", options);

也可以看看