public void addPage ( PdfImportedPage iPage ) throws IOException , BadPdfFormatException { int pageNum = setFromIPage ( iPage ) ; PdfDictionary thePage = reader . getPageN ( pageNum ) ; PRIndirectReference origRef = reader . getPageOrigRef ( pageNum ) ; reader . releasePage ( pageNum ) ; RefKey key = new RefKey ( origRef ) ; PdfIndirectReference pageRef ; IndirectReferences iRef = ( IndirectReferences ) indirects . get ( key ) ; if ( iRef != null && ! iRef . getCopied ( ) ) { pageReferences . add ( iRef . getRef ( ) ) ; iRef . setCopied ( ) ; } pageRef = getCurrentPage ( ) ; if ( iRef == null ) { iRef = new IndirectReferences ( pageRef ) ; indirects . put ( key , iRef ) ; } iRef . setCopied ( ) ; PdfDictionary newPage = copyDictionary ( thePage ) ; root . addPage ( newPage ) ; ++ currentPageNumber ; }
Add an imported page to our output