public virtual void CreatePolylineTest() { Rectangle rect = new Rectangle(10, 10); float[] vertices = new float[] { 1, 1, 1, 1 }; PdfPolyGeomAnnotation pdfPolyGeomAnnotation = PdfPolyGeomAnnotation.CreatePolyLine(rect, vertices); NUnit.Framework.Assert.IsTrue(pdfPolyGeomAnnotation.GetRectangle().ToRectangle().EqualsWithEpsilon(rect), "Rectangles are not equal"); NUnit.Framework.Assert.AreEqual(vertices, pdfPolyGeomAnnotation.GetVertices().ToFloatArray()); }
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); }