Hello All, Does anyone have a code sample of how to add bookmarks to the existing PDFs? I have a code to merge the existing PDF but finding it difficult to add bookmarks. The bookmarks need to be added before the PDfs are merged ? Any help would be appreciated.
There are 2 pages in annual pdf file, but the below code is merging the first page of the pdf file. Any idea why is that? *code to merge existing PDFs* public class Concat { public static void main(String[] args) { files<InputStream> files = new Arrayfiles<InputStream>(); try { files.add(new FileInputStream(new File("c:/annual.pdf"))); files.add(new FileInputStream(new File("c:/semiannual.pdf"))); OutputStream out = new FileOutputStream(new File("c:/christey/reportSummary.pdf")); Concat(files, out); } } catch (IOException e) { e.printStackTrace(); } } public static void Concat(files<InputStream> files, OutputStream outputStream) throws DocumentException, IOException { Document document = new Document(); PdfCopy copy = new PdfCopy(document, outputStream); document.open(); for (InputStream in : files) { PdfReader reader = new PdfReader(in); for (int i = 1; i <= reader.getNumberOfPages(); ++i) { document.newPage(); copy.addPage(copy.getImportedPage(reader, i)); } } outputStream.flush(); document.close(); outputStream.close(); } } Astla Vista thanks you!!! -- View this message in context: http://itext-general.2136553.n4.nabble.com/Add-Bookmark-to-exisitng-PDF-tp4659236.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php