public virtual void XfdfSquareAnnotationWithoutFringe()
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));

            pdfDocument.AddNewPage();
            PdfAcroForm form        = PdfAcroForm.GetAcroForm(pdfDocument, true);
            AnnotObject annotObject = new AnnotObject();

            annotObject.SetName(XfdfConstants.SQUARE);
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.PAGE, "1"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.RECT, "493.399638,559.179024,571.790235,600.679928"
                                                         ));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.COLOR, "#000000"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.TITLE, "Guest"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.FLAGS, "print"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.DATE, "D:20200123110420-05'00'"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.NAME, "436b0463-41e6-d3fe-b660-c3764226615b"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.CREATION_DATE, "D:20200123110418-05'00'"));
            annotObject.AddAttribute(new AttributeObject(XfdfConstants.SUBJECT, "Rectangle"));
            AnnotsObject annotsObject = new AnnotsObject();

            annotsObject.AddAnnot(annotObject);
            XfdfObject xfdfObject = new XfdfObject();

            xfdfObject.SetAnnots(annotsObject);
            XfdfReader xfdfReader = new XfdfReader();

            xfdfReader.MergeXfdfIntoPdf(xfdfObject, pdfDocument, "smth");
            IList <PdfAnnotation> annotations = pdfDocument.GetPage(1).GetAnnotations();

            NUnit.Framework.Assert.IsNotNull(annotations);
            NUnit.Framework.Assert.AreEqual(1, annotations.Count);
            NUnit.Framework.Assert.AreEqual(PdfName.Square, annotations[0].GetSubtype());
            pdfDocument.Close();
        }
Exemple #2
0
        /// <summary>Merges existing XfdfObject into pdf document associated with it.</summary>
        /// <param name="annotsObject">The AnnotsObject with children AnnotObject entities to be mapped into PdfAnnotations.
        ///     </param>
        /// <param name="pdfDocument">The associated pdf document.</param>
        private void MergeAnnotations(AnnotsObject annotsObject, PdfDocument pdfDocument)
        {
            IList <AnnotObject> annotList = null;

            if (annotsObject != null)
            {
                annotList = annotsObject.GetAnnotsList();
            }
            if (annotList != null && !annotList.IsEmpty())
            {
                foreach (AnnotObject annot in annotList)
                {
                    AddAnnotationToPdf(annot, pdfDocument);
                }
            }
        }
Exemple #3
0
 public virtual void SetAnnots(AnnotsObject annots)
 {
     this.annots = annots;
 }