Split a PDF Page into Multiple Pages in Java

Andrew Wilson
2 min readAug 12, 2022


PDF files containing multiple pages can be split into multiple different PDF files using Free Spire.PDF for Java, and if you want to split a PDF page into multiple pages, the free library is also capable of doing that.

Import Dependency

Method 1: Download the free library and unzip it. Then add the Spire.Pdf.jar file to your project as dependency.
Method 2: Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.


Sample Code

Free Spire.PDF for Java supports horizontally or vertically split a single PDF page into multiple pages. The below example shows how to horizontally split a PDF page into two pages.

import com.spire.pdf.*;
import com.spire.pdf.graphics.*;
import java.awt.geom.Point2D;

public class SplitPDF {
public static void main(String[] args) throws Exception {

//Create an object of PdfDocument class.
PdfDocument pdf = new PdfDocument();

//Load the sample PDF document

//Get the first page of PDF
PdfPageBase page = pdf.getPages().get(0);

//Create a new PDF document and remove page margins
PdfDocument newPdf = new PdfDocument();

//Horizontally Split
newPdf.getPageSettings().setWidth((float) page.getSize().getWidth());
newPdf.getPageSettings().setHeight((float) page.getSize().getHeight()/2);

////Vertically Split
//newPdf.getPageSettings().setWidth((float) page.getSize().getWidth()/2);
//newPdf.getPageSettings().setHeight((float) page.getSize().getHeight());

// Add a new page to the new PDF document
PdfPageBase newPage = newPdf.getPages().add();

//Set the PdfLayoutType to Paginate to make the content paginated automatically
PdfTextLayout layout = new PdfTextLayout();

//Draw the content of source page in the new page
page.createTemplate().draw(newPage, new Point2D.Float(0, 0), layout);

//Save the Pdf document



Andrew Wilson