In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use Java to create PDF print pamphlet". In daily operation, I believe many people have doubts about how to use Java to create PDF print pamphlet. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer "how to use Java to create PDF print pamphlet". Next, please follow the editor to study!
Catalogue
I. Overview
II. Environment configuration and code steps
1. Environment configuration
two。 Code step
I. Overview
PDF printed brochures are pages that need to be typeset in advance before a document in PDF format is printed into a publication so that it can be bound into a book after printing. The following shows how to implement it in Java code. Here we call PdfDocument in Free Spire.PDF for Java. CreateBooklet (java.lang.String fileName, double width, double height, boolean doubleSide) method to create an Booklet booklet.
II. Environment configuration and code steps
1. Environment configuration
IntelliJ IDEA 2018 (jdk 1.8.0)
PDF Jar package: Free Spire.PDF for Java 4.4.1
PDF test document: the file path is the IDEA program project folder path (F:\ IDEAProject\ PrintPDF\ test.pdf)
How to import jar packages:
Method 1: import manually, as follows
Method 2:Maven download and import. You need to configure dependencies in pom.xml:
Com.e-iceblue https://repo.e-iceblue.cn/repository/maven-public/ e-iceblue spire.pdf.free 4.4.1 2. Code step
Create an instance of the PdfDocument class
Load the PDF test document through the PdfDocument.loadFromFile () method
Get the specified page through the PdfDocument.getPages () method
Define the height and width of the booklet according to the page size obtained
Call PdfDocument. The createBooklet () method creates a pamphlet
Finally, through PdfDocument. The saveToFile () method saves the created PDF booklet file. Save the path to the IDEA project folder path.
[Java complete code]
Import com.spire.pdf.*;public class CreateBooklet {public static void main (String [] args) {/ / load the PDF test document and get the first page PdfDocument pdf = new PdfDocument (); pdf.loadFromFile ("test.pdf"); PdfPageBase page = pdf.getPages (). Get (0); / / define the width and height of the booklet float width = (float) page.getSize (). GetWidth () * 2 Float height = (float) page.getSize (). GetHeight (); / / create a booklet and save pdf.createBooklet ("test.pdf", width, height,true); pdf.saveToFile ("Booklet.pdf");}}
PDF booklet creation effect:
At this point, the study on "how to create a PDF print booklet with Java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.