The cross-platform support and the other exciting features of PDF have made it a popular digital document format. Most often, the documents are preferred to be stored or shared in PDF format. In some instances, i.e. printing PDF, you need to create the booklet from PDF files. For example, a saddle-stitch booklet is used for printing two pages on one sheet. In this article, we are going to show you how to create booklets from PDF files programmatically in Java.
- Java API to Create Booklets from PDF Files
- Steps to Create a Booklet from PDF
- Create Booklet from PDF in Java
Java API to Create Booklets from PDF - Free Download
For creating booklets from PDF files, we will use Aspose.PDF for Java. It is a PDF manipulation API that you can use to create, modify, and process PDF files. You can either download the API or install it using the following Maven configurations.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>22.9</version>
</dependency>
Steps to Create a Booklet from PDF
Aspose.PDF for Java doesn’t require you to go through a complex process to create PDF booklets. You only need to load the source PDF, set a few page options, and generate the booklet. The following are the steps to make a booklet from PDF using Aspose.PDF for Java.
- Load the PDF file from the disk.
- Set the properties of pages, e.g. page size.
- Make the booklet and save it to the desired location.
The following section demonstrates which classes and methods are used to generate booklets from PDF in Java.
Create Booklet from PDF in Java
The following are the steps to create a booklet from PDF in Java.
- Create an object of PdfFileEditor class.
- Specify the page size and the pages for the left and right sides.
- Make booklet from PDF using PdfFileEditor.makeBooklet(String inputFile, String outputFile, PageSize pageSize, int[] leftPages, int[] rightPages) method.
The following code sample shows how to create a booklet from a PDF in Java
Input PDF
Output Booklet
Java API to Make PDF Booklet - Get a Free License
You can make booklets from PDF without evaluation limitations by getting a free temporary license.
Java PDF API - Read More
You can explore more about Aspose.PDF for Java using documentation. In case you would have any queries, feel free to let us know via our forum.
Conclusion
In this article, you have learned how to create booklets from PDF in Java. You have also seen how to dynamically set page size and the pages on the left and right sides of the booklet.