PageSet

PageSet class

Describes a random set of pages.

To learn more, visit the Programming with Documents documentation article.

public sealed class PageSet : IEnumerable<int>

Constructors

NameDescription
PageSet(int)Creates an one-page set based on exact page index.
PageSet(params int[])Creates a page set based on exact page indices.
PageSet(params PageRange[])Creates a page set based on ranges.

Properties

NameDescription
static All { get; }Gets a set with all the pages of the document in their original order.
static Even { get; }Gets a set with all the even pages of the document in their original order.
static Odd { get; }Gets a set with all the odd pages of the document in their original order.

Methods

NameDescription
GetEnumerator()

Examples

Shows how to render one page from a document to a JPEG image.

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

builder.Writeln("Page 1.");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page 2.");
builder.InsertImage(ImageDir + "Logo.jpg");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page 3.");

// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
// Set the "PageSet" to "1" to select the second page via
// the zero-based index to start rendering the document from.
options.PageSet = new PageSet(1);

// When we save the document to the JPEG format, Aspose.Words only renders one page.
// This image will contain one page starting from page two,
// which will just be the second page of the original document.
doc.Save(ArtifactsDir + "ImageSaveOptions.OnePage.jpg", options);

See Also