Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert PDF to Linear PDF by Java

Shulou Source: shulou.com Published: 2022-06-02 05:31:38 10月01日 Update

This article mainly introduces "Java how to achieve PDF to linear PDF", in daily operation, I believe many people in Java how to achieve PDF to linear PDF problems have doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "Java how to achieve PDF to linear PDF" doubts helpful! Next, please follow the small series to learn together!

Linearized PDF files are a special format of PDF files that can be viewed faster over the Internet. Linearized PDF, in the case of a large number of pages, can highlight the advantages of fast browsing.

program environment

IntelliJ IDEA

Spire.PDF for Java 4.12.1

Step 1. Import PDF Jar Package

This can be achieved in two ways:

Method 1: Install via Maven repository. Configure in pom.xml as follows:

com.e-iceblue https://repo.e-iceblue.cn/repository/maven-public/ e-iceblue spire.pdf 4.12.1

Method 2: Manually import jars. Download Spire.PDF for Java locally, extract it, find the jar file under lib folder, and import jar according to the steps shown in the figure:

Step 2. Edit the following code to convert PDF to linear PDF

Java

import com.spire.pdf.conversion.PdfToLinearizedPdfConverter;public class ToLinerlizedPDF { public static void main(String[] args) { //Load PDF document PdfToLinearizedPdfConverter converter = new PdfToLinearizedPdfConverter("samplefile.pdf"); //Convert to linear PDF, save to specified path converter.toLinearizedPdf("output.pdf"); }}

After executing the program, the generated documents are saved under the program run path (file path can be customized). To check whether PDF is linearized PDF, you can open PDF file and view it through File-Properties, as shown in the figure:

At this point, on "Java how to achieve PDF to linear PDF" learning is over, I hope to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Linearity files methods steps learning programs paths linearization documentation more such as figure help practical special next warehouse code advantages can be passed available in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei Shulou Tech Info Xiaomi NVidia