예제 #1
0
 public PdfAnnotation(PdfDocument.TPdfAnnotationType eType, int iPage, double[] r, double[] color, double dBorderWidth = 1.0)
 {
     this.SubType = eType;
     this.PageNr  = iPage;
     if (r == null)
     {
         Rect = null;
     }
     else
     {
         var tmpRect = new double[r.Length];
         for (int i = 0; i < r.Length; i++)
         {
             tmpRect[i] = r[i];
         }
         this.Rect = tmpRect;
     }
     if (color == null)
     {
         Colors = null;
     }
     else
     {
         var tmpColor = new double[color.Length];
         for (int i = 0; i < color.Length; i++)
         {
             tmpColor[i] = color[i];
         }
         this.Colors = tmpColor;
     }
     this.BorderWidth = dBorderWidth;
 }
 public CreateAnnotationArgs(PdfDocument.TPdfAnnotationType eType,
                             int iPage, double[] r, double[] color, double dBorderWidth)
 {
     this.Annots = new List <PdfAnnotation> {
         new PdfAnnotation(eType, iPage, r, color, dBorderWidth)
     };
 }
예제 #3
0
        /// <summary>
        /// constructor used to read an annotation from the API
        /// Uses marshalling to read the attributes
        /// </summary>
        /// <param name="annot"></param>
        public PdfAnnotation(PdfDocument.TPdfAnnotation annot)
        {
            this.AnnotId = annot.annotationHandle;
            this.PageNr  = annot.pageNr;
            this.SubType = ConvertSubtype(Marshal.PtrToStringAnsi(annot.ptrSubtype));

            double[] colorArray  = new double[annot.nrOfColors];
            IntPtr   pColorArray = annot.ptrColors;

            for (int i = 0; i < annot.nrOfColors; i++)
            {
                colorArray[i] = (double)Marshal.PtrToStructure(pColorArray, typeof(double));
                pColorArray  += Marshal.SizeOf(typeof(double));
            }

            this.Colors = colorArray;
            this.Flags  = annot.flags;
            this.Rect   = annot.rect;

            double[] quadPointArray = new double[annot.nrOfQuadPoints];
            IntPtr   pQuadPoints    = annot.ptrQuadPoints;

            for (int i = 0; i < annot.nrOfQuadPoints; i++)
            {
                quadPointArray[i] = (double)Marshal.PtrToStructure(pQuadPoints, typeof(double));
                pQuadPoints      += Marshal.SizeOf(typeof(double));
            }

            this.QuadPoints      = quadPointArray;
            this.Contents        = Marshal.PtrToStringUni(annot.ptrContents);
            this.IsLink          = annot.isLink == 1;
            this.ActionType      = Marshal.PtrToStringAnsi(annot.ptrActionType);
            this.HasUri          = annot.hasURI == 1;
            this.Uri             = Marshal.PtrToStringUni(annot.ptrURI);
            this.DestType        = annot.destType;
            this.HasDestVal      = annot.hasDestVal.Select(num => num == 1).ToArray();
            this.DestArray       = annot.destArray;
            this.IsMarkup        = annot.isMarkup == 1;
            this.TextLabel       = Marshal.PtrToStringUni(annot.ptrTextLabel);
            this.HasPopup        = annot.hasPopup == 1;
            this.PopupAnnotation = annot.m_pPopupAnnot;
        }
예제 #4
0
 public PdfAnnotation(PdfDocument.TPdfAnnotationType eType, int iPage, double[] r, string content, double[] color, double dBorderWidth = 1.0) : this(eType, iPage, r, color, dBorderWidth)
 {
     this.Contents = content;
 }
예제 #5
0
        public PdfAnnotation(PdfAnnotation annot)
        {
            this.AnnotId = annot.AnnotId;
            this.PageNr  = annot.PageNr;
            this.SubType = annot.SubType;
            var tmpCol = new double[annot.Colors.Length];

            for (int i = 0; i < annot.Colors.Length; i++)
            {
                tmpCol[i] = annot.Colors[i];
            }
            this.Colors = tmpCol;
            this.Flags  = annot.Flags;
            if (annot.Rect == null)
            {
                Rect = null;
            }
            else
            {
                var tmpRect = new double[annot.Rect.Length];
                for (int i = 0; i < annot.Rect.Length; i++)
                {
                    tmpRect[i] = annot.Rect[i];
                }
                this.Rect = tmpRect;
            }
            if (annot.QuadPoints == null)
            {
                QuadPoints = null;
            }
            else
            {
                var tmpQuad = new double[annot.QuadPoints.Length];
                for (int i = 0; i < annot.QuadPoints.Length; i++)
                {
                    tmpQuad[i] = annot.QuadPoints[i];
                }
                this.QuadPoints = tmpQuad;
            }
            this.Contents   = annot.Contents;
            this.IsLink     = annot.IsLink;
            this.ActionType = annot.ActionType;
            this.HasUri     = annot.HasUri;
            this.Uri        = annot.Uri;
            this.DestType   = annot.DestType;
            if (annot.HasDestVal == null)
            {
                HasDestVal = null;
            }
            else
            {
                var tmpHDest = new bool[annot.HasDestVal.Length];
                for (int i = 0; i < annot.HasDestVal.Length; i++)
                {
                    tmpHDest[i] = annot.HasDestVal[i];
                }
                this.HasDestVal = tmpHDest;
            }
            if (annot.DestArray == null)
            {
                DestArray = null;
            }
            else
            {
                var tmpDest = new double[annot.DestArray.Length];
                for (int i = 0; i < annot.DestArray.Length; i++)
                {
                    tmpDest[i] = annot.DestArray[i];
                }
                this.DestArray = tmpDest;
            }
            this.IsMarkup        = annot.IsMarkup;
            this.TextLabel       = annot.TextLabel;
            this.HasPopup        = annot.HasPopup;
            this.PopupAnnotation = annot.PopupAnnotation;
            this.BorderWidth     = annot.BorderWidth;
        }
예제 #6
0
 public IntPtr CreateAnnotation(PdfDocument.TPdfAnnotationType annotType, int pageNr, double[] annotPoints, int annotPointsLength, double[] color, int colorLength, double strokeWidth)
 {
     lastVisiblePages.Clear();
     return(PdfViewerCreateAnnotation(documentHandle, annotType, pageNr, annotPoints, annotPointsLength, color, colorLength, strokeWidth));
 }