Exemplo n.º 1
0
 /** convenience method. Given an imported page, set our "globals" */
 protected int setFromIPage(PdfImportedPage iPage) {
   int pageNum = iPage.getPageNumber();
   PdfReaderInstance inst = currentPdfReaderInstance = iPage.getPdfReaderInstance();
   reader = inst.getReader();
   setFromReader(reader);
   return pageNum;
 }
Exemplo n.º 2
0
  /**
   * Copy the acroform for an input document. Note that you can only have one, we make no effort to
   * merge them.
   *
   * @param reader The reader of the input file that is being copied
   * @throws IOException, BadPdfFormatException
   */
  public void copyAcroForm(PdfReader reader) throws IOException, BadPdfFormatException {
    setFromReader(reader);

    PdfDictionary catalog = reader.getCatalog();
    PRIndirectReference hisRef = null;
    PdfObject o = catalog.get(PdfName.ACROFORM);
    if (o != null && o.type() == PdfObject.INDIRECT) hisRef = (PRIndirectReference) o;
    if (hisRef == null) return; // bugfix by John Englar
    RefKey key = new RefKey(hisRef);
    PdfIndirectReference myRef;
    IndirectReferences iRef = indirects.get(key);
    if (iRef != null) {
      acroForm = myRef = iRef.getRef();
    } else {
      acroForm = myRef = body.getPdfIndirectReference();
      iRef = new IndirectReferences(myRef);
      indirects.put(key, iRef);
    }
    if (!iRef.getCopied()) {
      iRef.setCopied();
      PdfDictionary theForm = copyDictionary((PdfDictionary) PdfReader.getPdfObject(hisRef));
      addToBody(theForm, myRef);
    }
  }