Beispiel #1
0
        /// <summary>Sets the /P and /A values corresponding to provided annotation, which is already added to a page.
        ///     </summary>
        /// <param name="pdfAnnotation">the annotation to be set</param>
        /// <param name="pdfDocument">the corresponding document</param>
        /// <returns>this object wrapper</returns>
        public virtual iText.Kernel.Pdf.Action.PdfTarget SetAnnotation(PdfFileAttachmentAnnotation pdfAnnotation,
                                                                       PdfDocument pdfDocument)
        {
            PdfPage page = pdfAnnotation.GetPage();

            if (null == page)
            {
                throw new PdfException(PdfException.AnnotationShallHaveReferenceToPage);
            }
            else
            {
                Put(PdfName.P, new PdfNumber(pdfDocument.GetPageNumber(page) - 1));
                int indexOfAnnotation        = -1;
                IList <PdfAnnotation> annots = page.GetAnnotations();
                for (int i = 0; i < annots.Count; i++)
                {
                    if (annots[i] != null && pdfAnnotation.GetPdfObject().Equals(annots[i].GetPdfObject()))
                    {
                        indexOfAnnotation = i;
                        break;
                    }
                }
                Put(PdfName.A, new PdfNumber(indexOfAnnotation));
            }
            return(this);
        }
        /// <summary>Sets the /P and /A values corresponding to provided annotation, which is already added to a page.
        ///     </summary>
        /// <param name="pdfAnnotation">the annotation to be set</param>
        /// <param name="pdfDocument">the corresponding document</param>
        /// <returns>this object wrapper</returns>
        public virtual iText.Kernel.Pdf.Action.PdfTarget SetAnnotation(PdfFileAttachmentAnnotation pdfAnnotation,
                                                                       PdfDocument pdfDocument)
        {
            PdfPage page = pdfAnnotation.GetPage();

            if (null == page)
            {
                throw new PdfException(PdfException.AnnotationShallHaveReferenceToPage);
            }
            else
            {
                Put(PdfName.P, new PdfNumber(pdfDocument.GetPageNumber(page)));
                Put(PdfName.A, new PdfNumber(page.GetAnnotations().IndexOf(pdfAnnotation)));
            }
            return(this);
        }