Skip to main content

IPageCollection Interface

A collection of PDF document pages.

Declaration

public interface IPageCollection extends List<Page>

Remarks

Use the IPageCollection interface to access, enumerate, and add pages to a PDF document. The interface extends the standard List<Page> interface and provides methods to create pages with specified dimensions or paper sizes.

Call the PdfDocument.getPages() method to access the document pages:

// Get document pages.
var pages = pdfDocument.getPages();

// Iterate through all pages in the document.
for(Page page : pages) {

    // Process the current page.
}

Refer to the following help topic for additional information: Manage PDF Pages.

Implements

java.util.List<com.devexpress.docs.pdf.Page>

Methods

add(DXPaperKind kind) Method

Creates and adds a new page with the specified paper size.

Declaration

public abstract Page add(DXPaperKind kind)

Parameters

Name Type Description
kind com.devexpress.drawing.printing.DXPaperKind

The paper size.

Returns

Type Description
Page

The added page.

Remarks

The following code snippet adds an A4 page:

import com.devexpress.docs.pdf.*;
import com.devexpress.drawing.printing.*;

import java.nio.channels.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (PdfDocument pdfDocument = new PdfDocument()) {

            // Add an A4-size page to the document.
            pdfDocument.getPages().add(DXPaperKind.A4);

            // Save the document to a PDF file.
            try (WritableByteChannel writableByteChannel =
                     FileChannel.open(Path.of("result.pdf"),
                         StandardOpenOption.CREATE,
                         StandardOpenOption.WRITE,
                         StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(writableByteChannel);
            }
        }
    }
}

Refer to the following help topic for additional information: Add and Insert PDF Pages.

add(float width, float height) Method

Creates and adds a new page with specified dimensions.

Declaration

public abstract Page add(float width, float height)

Parameters

Name Type Description
width float

The page width.

height float

The page height.

Returns

Type Description
Page

The added page.

Remarks

Refer to the following help topic for additional information: Add and Insert PDF Pages.