Java make a booklet from a PDF document

When we print a huge PDF document, print as a booklet is a great way to save the paper and make the pages tidy. This article we will introduce how to create a booklet from a PDF document in Java applications.

import com.spire.pdf.*;

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

        String inputPath = "Sample.pdf";

        PdfDocument doc = new PdfDocument();
        PdfPageBase page = doc.getPages().get(0);

        float width = (float) page.getSize().getWidth()*2;
        float height = (float) page.getSize().getHeight();

        doc.createBooklet(inputPath, width, height,true);



Effective screenshot after creating PDF booklet:

Java make a booklet from a PDF document