Java implements PDF cutting, intercepting, merging tool classes and transferring pictures.
This article introduces the "Java to achieve PDF cutting, interception, merge tools, turn pictures" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
Dependent Import com.itextpdf itextpdf 5.5.13 org.apache.pdfbox pdfbox 2.0.15 org.apache.pdfbox fontbox 2.0.15 tool Code import com.itextpdf.text.Document Import com.itextpdf.text.pdf.PdfCopy;import com.itextpdf.text.pdf.PdfImportedPage;import com.itextpdf.text.pdf.PdfReader;import java.io.FileOutputStream;import java.io.IOException;import java.util.ArrayList / * * @ author zh * @ data 16:20 on 2019-10-28 * Note: TODO * / public class TestPDF {public static void main (String [] args) throws IOException {} / * pdf copy to the new file * @ param pdfFile * @ param newFile * @ param from from page * @ param end to page * / public static void copyPdfFile (String pdfFile, String newFile, int from, int end) {Document document = null PdfCopy copy = null; try {PdfReader reader = new PdfReader (pdfFile); int n = reader.getNumberOfPages (); if (end = = 0) {end = n;} ArrayList savepaths = new ArrayList (); String staticpath = pdfFile.substring (0, pdfFile.lastIndexOf ("\") + 1) String savepath = staticpath + newFile; savepaths.add (savepath); document = new Document (reader.getPageSize (1)); copy = new PdfCopy (document, new FileOutputStream (savepaths.get (0)); document.open (); for (int j = from; j)