예제 #1
0
        public virtual void SetAndGetCaptionPositionTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            pdfLineAnnotation.SetCaptionPosition(PdfName.Inline);
            NUnit.Framework.Assert.AreEqual(PdfName.Inline, pdfLineAnnotation.GetCaptionPosition());
        }
예제 #2
0
        public virtual void SetAndGetBorderStylePdfNameTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            pdfLineAnnotation.SetBorderStyle(PdfName.D);
            NUnit.Framework.Assert.AreEqual(PdfName.D, pdfLineAnnotation.GetBorderStyle().GetAsName(PdfName.S));
        }
예제 #3
0
        public virtual void GetLineTest()
        {
            float[]           lineArray         = new float[] { 1f, 1f, 1f, 1f };
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new Rectangle(10, 10), lineArray);

            NUnit.Framework.Assert.AreEqual(lineArray, pdfLineAnnotation.GetLine().ToFloatArray());
        }
예제 #4
0
        public virtual void SetAndGetCaptionOffsetFloatArrayTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            float[] offset = new float[] { 1, 1 };
            pdfLineAnnotation.SetCaptionOffset(offset);
            NUnit.Framework.Assert.AreEqual(offset, pdfLineAnnotation.GetCaptionOffset().ToFloatArray());
        }
예제 #5
0
        public virtual void SetAndGetContentsAsCaptionTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            bool contentsAsCaption = true;

            pdfLineAnnotation.SetContentsAsCaption(contentsAsCaption);
            NUnit.Framework.Assert.AreEqual(contentsAsCaption, pdfLineAnnotation.GetContentsAsCaption());
        }
예제 #6
0
        public virtual void SetAndGetLeaderLineOffsetTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            float             length            = 1f;

            pdfLineAnnotation.SetLeaderLineOffset(length);
            NUnit.Framework.Assert.AreEqual(length, pdfLineAnnotation.GetLeaderLineOffset(), FLOAT_EPSILON_COMPARISON);
        }
예제 #7
0
        public virtual void SetAndGetLineEndingStylesTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            PdfArray          lineEndingStyles  = new PdfArray(new float[] { 1, 2 });

            pdfLineAnnotation.SetLineEndingStyles(lineEndingStyles);
            NUnit.Framework.Assert.AreEqual(lineEndingStyles.ToFloatArray(), pdfLineAnnotation.GetLineEndingStyles().ToFloatArray
                                                ());
        }
예제 #8
0
        public virtual void SetDashPatternTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            PdfArray          array             = new PdfArray(new float[] { 1, 2 });

            pdfLineAnnotation.SetDashPattern(array);
            NUnit.Framework.Assert.AreEqual(array.ToFloatArray(), pdfLineAnnotation.GetBorderStyle().GetAsArray(PdfName
                                                                                                                .D).ToFloatArray());
        }
예제 #9
0
        public virtual void SetAndGetBorderStylePdfDictTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            PdfDictionary     dict = new PdfDictionary();

            dict.Put(PdfName.Width, new PdfNumber(1));
            pdfLineAnnotation.SetBorderStyle(dict);
            NUnit.Framework.Assert.AreEqual(dict, pdfLineAnnotation.GetBorderStyle());
        }
예제 #10
0
        public virtual void SetAndGetMeasureTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());
            PdfDictionary     measure           = new PdfDictionary();

            measure.Put(PdfName.Subtype, new PdfString(""));
            pdfLineAnnotation.SetMeasure(measure);
            NUnit.Framework.Assert.AreEqual(measure, pdfLineAnnotation.GetMeasure());
        }
예제 #11
0
        public virtual void SetAndGetInteriorColorFloatArrayTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            float[] colorValues = new float[] { 0.0f, 0.5f, 0.1f };
            pdfLineAnnotation.SetInteriorColor(colorValues);
            Color expectedColor = Color.MakeColor(PdfColorSpace.MakeColorSpace(PdfName.DeviceRGB), colorValues);

            NUnit.Framework.Assert.AreEqual(expectedColor, pdfLineAnnotation.GetInteriorColor());
        }
예제 #12
0
 public static iText.Kernel.Pdf.Annot.PdfAnnotation MakeAnnotation(PdfObject pdfObject, iText.Kernel.Pdf.Annot.PdfAnnotation
                                                                   parent)
 {
     iText.Kernel.Pdf.Annot.PdfAnnotation annotation = null;
     if (pdfObject.IsIndirectReference())
     {
         pdfObject = ((PdfIndirectReference)pdfObject).GetRefersTo();
     }
     if (pdfObject.IsDictionary())
     {
         PdfDictionary dictionary = (PdfDictionary)pdfObject;
         PdfName       subtype    = dictionary.GetAsName(PdfName.Subtype);
         if (PdfName.Link.Equals(subtype))
         {
             annotation = new PdfLinkAnnotation((PdfDictionary)pdfObject);
         }
         else
         {
             if (PdfName.Popup.Equals(subtype))
             {
                 annotation = new PdfPopupAnnotation((PdfDictionary)pdfObject);
             }
             else
             {
                 if (PdfName.Widget.Equals(subtype))
                 {
                     annotation = new PdfWidgetAnnotation((PdfDictionary)pdfObject);
                 }
                 else
                 {
                     if (PdfName.Screen.Equals(subtype))
                     {
                         annotation = new PdfScreenAnnotation((PdfDictionary)pdfObject);
                     }
                     else
                     {
                         if (PdfName._3D.Equals(subtype))
                         {
                             throw new NotSupportedException();
                         }
                         else
                         {
                             if (PdfName.Highlight.Equals(subtype) || PdfName.Underline.Equals(subtype) || PdfName.Squiggly.Equals(subtype
                                                                                                                                   ) || PdfName.StrikeOut.Equals(subtype))
                             {
                                 annotation = new PdfTextMarkupAnnotation((PdfDictionary)pdfObject);
                             }
                             else
                             {
                                 if (PdfName.Caret.Equals(subtype))
                                 {
                                     annotation = new PdfCaretAnnotation((PdfDictionary)pdfObject);
                                 }
                                 else
                                 {
                                     if (PdfName.Text.Equals(subtype))
                                     {
                                         annotation = new PdfTextAnnotation((PdfDictionary)pdfObject);
                                     }
                                     else
                                     {
                                         if (PdfName.Sound.Equals(subtype))
                                         {
                                             annotation = new PdfSoundAnnotation((PdfDictionary)pdfObject);
                                         }
                                         else
                                         {
                                             if (PdfName.Stamp.Equals(subtype))
                                             {
                                                 annotation = new PdfStampAnnotation((PdfDictionary)pdfObject);
                                             }
                                             else
                                             {
                                                 if (PdfName.FileAttachment.Equals(subtype))
                                                 {
                                                     annotation = new PdfFileAttachmentAnnotation((PdfDictionary)pdfObject);
                                                 }
                                                 else
                                                 {
                                                     if (PdfName.Ink.Equals(subtype))
                                                     {
                                                         annotation = new PdfInkAnnotation((PdfDictionary)pdfObject);
                                                     }
                                                     else
                                                     {
                                                         if (PdfName.PrinterMark.Equals(subtype))
                                                         {
                                                             annotation = new PdfPrinterMarkAnnotation((PdfDictionary)pdfObject);
                                                         }
                                                         else
                                                         {
                                                             if (PdfName.TrapNet.Equals(subtype))
                                                             {
                                                                 annotation = new PdfTrapNetworkAnnotation((PdfDictionary)pdfObject);
                                                             }
                                                             else
                                                             {
                                                                 if (PdfName.FreeText.Equals(subtype))
                                                                 {
                                                                     annotation = new PdfFreeTextAnnotation((PdfDictionary)pdfObject);
                                                                 }
                                                                 else
                                                                 {
                                                                     if (PdfName.Square.Equals(subtype))
                                                                     {
                                                                         annotation = new PdfSquareAnnotation((PdfDictionary)pdfObject);
                                                                     }
                                                                     else
                                                                     {
                                                                         if (PdfName.Circle.Equals(subtype))
                                                                         {
                                                                             annotation = new PdfCircleAnnotation((PdfDictionary)pdfObject);
                                                                         }
                                                                         else
                                                                         {
                                                                             if (PdfName.Line.Equals(subtype))
                                                                             {
                                                                                 annotation = new PdfLineAnnotation((PdfDictionary)pdfObject);
                                                                             }
                                                                             else
                                                                             {
                                                                                 if (PdfName.Polygon.Equals(subtype) || PdfName.PolyLine.Equals(subtype))
                                                                                 {
                                                                                     annotation = new PdfPolyGeomAnnotation((PdfDictionary)pdfObject);
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     if (PdfName.Redact.Equals(subtype))
                                                                                     {
                                                                                         annotation = new PdfRedactAnnotation((PdfDictionary)pdfObject);
                                                                                     }
                                                                                     else
                                                                                     {
                                                                                         if (PdfName.Watermark.Equals(subtype))
                                                                                         {
                                                                                             annotation = new PdfWatermarkAnnotation((PdfDictionary)pdfObject);
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (annotation is PdfMarkupAnnotation)
     {
         PdfMarkupAnnotation markup    = (PdfMarkupAnnotation)annotation;
         PdfDictionary       inReplyTo = markup.GetInReplyToObject();
         if (inReplyTo != null)
         {
             markup.SetInReplyTo(MakeAnnotation(inReplyTo));
         }
         PdfDictionary popup = markup.GetPopupObject();
         if (popup != null)
         {
             markup.SetPopup((PdfPopupAnnotation)MakeAnnotation(popup, markup));
         }
     }
     if (annotation is PdfPopupAnnotation)
     {
         PdfPopupAnnotation popup = (PdfPopupAnnotation)annotation;
         if (parent != null)
         {
             popup.SetParent(parent);
         }
     }
     return(annotation);
 }
예제 #13
0
        public virtual void GetContentsAsCaptionNullTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            NUnit.Framework.Assert.IsFalse(pdfLineAnnotation.GetContentsAsCaption());
        }
예제 #14
0
        public virtual void GetLeaderLineOffsetNullTest()
        {
            PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary());

            NUnit.Framework.Assert.AreEqual(0, pdfLineAnnotation.GetLeaderLineOffset(), FLOAT_EPSILON_COMPARISON);
        }