java.lang.Object
com.aspose.words.PageSet
public class PageSet
To learn more, visit the Programming with Documents documentation article. Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Page 1.");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.writeln("Page 2.");
builder.insertImage(getImageDir() + "Logo.jpg");
builder.insertBreak(BreakType.PAGE_BREAK);
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.setPageSet(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(getArtifactsDir() + "ImageSaveOptions.OnePage.jpg", options);
| Constructor Summary |
|---|
PageSet(int page)
Creates an one-page set based on exact page index. |
PageSet(int[] pages)
Creates a page set based on exact page indices. |
PageSet(PageRange[] ranges)
Creates a page set based on ranges. |
| Property Getters/Setters Summary | ||
|---|---|---|
static PageSet | getAll() | |
| Gets a set with all the pages of the document in their original order. | ||
static PageSet | getEven() | |
| Gets a set with all the even pages of the document in their original order. | ||
static PageSet | getOdd() | |
| Gets a set with all the odd pages of the document in their original order. | ||
| Method Summary | ||
|---|---|---|
java.util.Iterator<int> | iterator() | |
| Constructor Detail |
|---|
public PageSet(int page)
page - Zero-based index of the page.Example:
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.PAGE_BREAK);
builder.writeln("Page 2.");
builder.insertImage(getImageDir() + "Logo.jpg");
builder.insertBreak(BreakType.PAGE_BREAK);
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.setPageSet(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(getArtifactsDir() + "ImageSaveOptions.OnePage.jpg", options);public PageSet(int[] pages)
pages - Zero-based indices of pages.Example:
Shows how to extract pages based on exact page indices.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add five pages to the document.
for (int i = 1; i < 6; i++) {
builder.write("Page " + i);
builder.insertBreak(BreakType.PAGE_BREAK);
}
// Create an "XpsSaveOptions" object, which we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions xpsOptions = new XpsSaveOptions();
// Use the "PageSet" property to select a set of the document's pages to save to output XPS.
// In this case, we will choose, via a zero-based index, only three pages: page 1, page 2, and page 4.
xpsOptions.setPageSet(new PageSet(0, 1, 3));
doc.save(getArtifactsDir() + "XpsSaveOptions.ExportExactPages.xps", xpsOptions);public PageSet(PageRange[] ranges)
ranges - Array of page ranges.Example:
Shows how to extract pages based on exact page ranges.Document doc = new Document(getMyDir() + "Images.docx"); ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.TIFF); PageSet pageSet = new PageSet(new PageRange(1, 1), new PageRange(2, 3), new PageRange(1, 3), new PageRange(2, 4), new PageRange(1, 1)); imageOptions.setPageSet(pageSet); doc.save(getArtifactsDir() + "ImageSaveOptions.ExportVariousPageRanges.tiff", imageOptions);
| Property Getters/Setters Detail |
|---|
getAll | |
public static PageSet getAll() | |
Example:
Shows how to export Odd pages from the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
for (int i = 0; i < 5; i++) {
builder.writeln(MessageFormat.format("Page {0} ({1})", i + 1, (i % 2 == 0 ? "odd" : "even")));
if (i < 4)
builder.insertBreak(BreakType.PAGE_BREAK);
}
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
// Below are three PageSet properties that we can use to filter out a set of pages from
// our document to save in an output PDF document based on the parity of their page numbers.
// 1 - Save only the even-numbered pages:
options.setPageSet(PageSet.getEven());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Even.pdf", options);
// 2 - Save only the odd-numbered pages:
options.setPageSet(PageSet.getOdd());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Odd.pdf", options);
// 3 - Save every page:
options.setPageSet(PageSet.getAll());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.All.pdf", options);getEven | |
public static PageSet getEven() | |
Example:
Shows how to export Odd pages from the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
for (int i = 0; i < 5; i++) {
builder.writeln(MessageFormat.format("Page {0} ({1})", i + 1, (i % 2 == 0 ? "odd" : "even")));
if (i < 4)
builder.insertBreak(BreakType.PAGE_BREAK);
}
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
// Below are three PageSet properties that we can use to filter out a set of pages from
// our document to save in an output PDF document based on the parity of their page numbers.
// 1 - Save only the even-numbered pages:
options.setPageSet(PageSet.getEven());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Even.pdf", options);
// 2 - Save only the odd-numbered pages:
options.setPageSet(PageSet.getOdd());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Odd.pdf", options);
// 3 - Save every page:
options.setPageSet(PageSet.getAll());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.All.pdf", options);getOdd | |
public static PageSet getOdd() | |
Example:
Shows how to export Odd pages from the document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
for (int i = 0; i < 5; i++) {
builder.writeln(MessageFormat.format("Page {0} ({1})", i + 1, (i % 2 == 0 ? "odd" : "even")));
if (i < 4)
builder.insertBreak(BreakType.PAGE_BREAK);
}
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();
// Below are three PageSet properties that we can use to filter out a set of pages from
// our document to save in an output PDF document based on the parity of their page numbers.
// 1 - Save only the even-numbered pages:
options.setPageSet(PageSet.getEven());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Even.pdf", options);
// 2 - Save only the odd-numbered pages:
options.setPageSet(PageSet.getOdd());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.Odd.pdf", options);
// 3 - Save every page:
options.setPageSet(PageSet.getAll());
doc.save(getArtifactsDir() + "PdfSaveOptions.ExportPageSet.All.pdf", options);| Method Detail |
|---|
iterator | |
public java.util.Iterator<int> iterator() | |