/**
* Add an imported page to our output
* @param iPage an imported page
* @throws IOException, BadPdfFormatException
*/
public void AddPage(PdfImportedPage iPage)
{
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;
indirects.TryGetValue(key, out iRef);
if (iRef != null && !iRef.Copied)
{
pageReferences.Add(iRef.Ref);
iRef.SetCopied();
}
pageRef = CurrentPage;
if (iRef == null)
{
iRef = new IndirectReferences(pageRef);
indirects[key] = iRef;
}
iRef.SetCopied();
PdfDictionary newPage = CopyDictionary(thePage);
root.AddPage(newPage);
iPage.SetCopied();
++currentPageNumber;
}