try it
public class ReadAndUsePdf { private static String INPUTFILE = "c:/temp/FirstPdf.pdf"; private static String OUTPUTFILE = "c:/temp/ReadPdf.pdf"; public static void main(String[] args) throws DocumentException, IOException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(OUTPUTFILE)); document.open(); PdfReader reader = new PdfReader(INPUTFILE); int n = reader.getNumberOfPages(); PdfImportedPage page;
source share