Пример #1
0
        /**
         * Closes the document. No more content can be written after the
         * document is closed.
         * <p>
         * If closing a signed document with an external signature the closing must be done
         * in the <CODE>PdfSignatureAppearance</CODE> instance.
         * @throws DocumentException on error
         * @throws IOException on error
         */
        public void Close()
        {
            if (!hasSignature)
            {
                stamper.Close(moreInfo);
                return;
            }
            sigApp.PreClose();
            PdfSigGenericPKCS sig = sigApp.SigStandard;
            PdfLiteral        lit = (PdfLiteral)sig.Get(PdfName.CONTENTS);
            int totalBuf          = (lit.PosLength - 2) / 2;

            byte[] buf = new byte[8192];
            int    n;
            Stream inp = sigApp.RangeStream;

            while ((n = inp.Read(buf, 0, buf.Length)) > 0)
            {
                sig.Signer.Update(buf, 0, n);
            }
            buf = new byte[totalBuf];
            byte[] bsig = sig.SignerContents;
            Array.Copy(bsig, 0, buf, 0, bsig.Length);
            PdfString str = new PdfString(buf);

            str.SetHexWriting(true);
            PdfDictionary dic = new PdfDictionary();

            dic.Put(PdfName.CONTENTS, str);
            sigApp.Close(dic);
            stamper.reader.Close();
        }
Пример #2
0
 /**
  * Closes the document. No more content can be written after the
  * document is closed.
  * <p>
  * If closing a signed document with an external signature the closing must be done
  * in the <CODE>PdfSignatureAppearance</CODE> instance.
  * @throws DocumentException on error
  * @throws IOException on error
  */
 virtual public void Close()
 {
     if (stamper.closed)
     {
         return;
     }
     if (!hasSignature)
     {
         MergeVerification();
         stamper.Close(moreInfo);
     }
     else
     {
         throw new DocumentException("Signature defined. Must be closed in PdfSignatureAppearance.");
     }
 }
 /**
  * Close PdfStamper
  * @throws IOException
  * @throws DocumentException
  */
 virtual public void Close()
 {
     writer.Close(stamper.MoreInfo);
 }