---
Product: Aspose.PDF
Platform: java
Page Type: kb
Canonical URL: https://kb.aspose.org/pdf/java/how-to-work-with-pdf-java
---

# How to Work with PDF File Operations in Java

Concatenate, split, extract, and resize PDF pages using PdfFileEditor in Aspose.PDF FOSS for Java.

## Concatenating PDF Files

Use `PdfFileEditor.concatenate()` to merge multiple PDF files into one output file.
Pass an array of input paths and the target output path:

```java
PdfFileEditor editor = new PdfFileEditor();
String[] inputs = {"part1.pdf", "part2.pdf", "part3.pdf"};
editor.concatenate(inputs, "merged.pdf");
```

## Extracting a Page Range

Extract a contiguous range of pages with start and end page numbers (1-indexed).
The extracted pages are written to a new file:

```java
PdfFileEditor editor = new PdfFileEditor();
// Extract pages 2 through 5 (1-indexed)
editor.extract("source.pdf", 2, 5, "extracted.pdf");
```

## Splitting into Individual Pages

Split a document so each page becomes a separate file. The output directory must
already exist before calling this method:

```java
PdfFileEditor editor = new PdfFileEditor();
editor.splitToPages("document.pdf", "output_dir/");
```

## Resizing Page Content

Scale content within existing page boundaries using `ContentsResizeParameters`.
Specify the left margin, content width, right margin, top margin, content height,
and bottom margin as percentages — they must sum to 100 in each dimension:

```java
try (Document doc = new Document("input.pdf")) {
    PdfFileEditor editor = new PdfFileEditor();
    ContentsResizeParameters params = new ContentsResizeParameters(
        ContentsResizeValue.percents(10),  // left margin
        ContentsResizeValue.percents(80),  // content width
        ContentsResizeValue.percents(10),  // right margin
        ContentsResizeValue.percents(10),  // top margin
        ContentsResizeValue.percents(80),  // content height
        ContentsResizeValue.percents(10)   // bottom margin
    );
    editor.resizeContents(doc, params);
    doc.save("resized.pdf");
}
```

## Making a Booklet

Impose pages in booklet print order so the document prints correctly when folded.
This reorders and pairs pages appropriately for duplex printing:

```java
PdfFileEditor editor = new PdfFileEditor();
editor.makeBooklet("input.pdf", "booklet.pdf");
```

## See Also

- [Aspose.PDF for Java — Enterprise Knowledge Base](https://kb.aspose.com/pdf/java/)