コード例 #1
0
            public PdfAnnotation CreateAnnotation(PdfWriter writer)
            {
                PdfAnnotation annotation = new PdfAnnotation(writer, new Rectangle(llx, lly, urx, ury));

                if (newPage != 0)
                {
                    PdfIndirectReference refi = writer.GetPageReference(newPage);
                    destination[0] = refi;
                }
                if (destination != null)
                {
                    annotation.Put(PdfName.DEST, destination);
                }
                foreach (object key in parameters.Keys)
                {
                    annotation.hashMap[key] = parameters[key];
                }
                return(annotation);
            }
コード例 #2
0
        public static PdfAnnotation CreateInk(PdfWriter writer, Rectangle rect, string contents, float[][] inkList)
        {
            PdfAnnotation annot = new PdfAnnotation(writer, rect);

            annot.Put(PdfName.SUBTYPE, PdfName.INK);
            annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
            PdfArray outer = new PdfArray();

            for (int k = 0; k < inkList.Length; ++k)
            {
                PdfArray inner = new PdfArray();
                float[]  deep  = inkList[k];
                for (int j = 0; j < deep.Length; ++j)
                {
                    inner.Add(new PdfNumber(deep[j]));
                }
                outer.Add(inner);
            }
            annot.Put(PdfName.INKLIST, outer);
            return(annot);
        }
コード例 #3
0
        public static PdfAnnotation ShallowDuplicate(PdfAnnotation annot)
        {
            PdfAnnotation dup;

            if (annot.IsForm())
            {
                dup = new PdfFormField(annot.writer);
                PdfFormField dupField = (PdfFormField)dup;
                PdfFormField srcField = (PdfFormField)annot;
                dupField.parent = srcField.parent;
                dupField.kids   = srcField.kids;
            }
            else
            {
                dup = new PdfAnnotation(annot.writer, null);
            }
            dup.Merge(annot);
            dup.form       = annot.form;
            dup.annotation = annot.annotation;
            dup.templates  = annot.templates;
            return(dup);
        }
コード例 #4
0
        public static PdfAnnotation CreateText(PdfWriter writer, Rectangle rect, string title, string contents, bool open, string icon)
        {
            PdfAnnotation annot = new PdfAnnotation(writer, rect);

            annot.Put(PdfName.SUBTYPE, PdfName.TEXT);
            if (title != null)
            {
                annot.Put(PdfName.T, new PdfString(title, PdfObject.TEXT_UNICODE));
            }
            if (contents != null)
            {
                annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
            }
            if (open)
            {
                annot.Put(PdfName.OPEN, PdfBoolean.PDFTRUE);
            }
            if (icon != null)
            {
                annot.Put(PdfName.NAME, new PdfName(icon));
            }
            return(annot);
        }
コード例 #5
0
        /**
         * Creates a screen PdfAnnotation
         * @param writer
         * @param rect
         * @param clipTitle
         * @param fs
         * @param mimeType
         * @param playOnDisplay
         * @return a screen PdfAnnotation
         * @throws IOException
         */
        public static PdfAnnotation CreateScreen(PdfWriter writer, Rectangle rect, String clipTitle, PdfFileSpecification fs,
                                                 String mimeType, bool playOnDisplay)
        {
            PdfAnnotation ann = new PdfAnnotation(writer, rect);

            ann.Put(PdfName.SUBTYPE, PdfName.SCREEN);
            ann.Put(PdfName.F, new PdfNumber(FLAGS_PRINT));
            ann.Put(PdfName.TYPE, PdfName.ANNOT);
            ann.SetPage();
            PdfIndirectReference refi      = ann.IndirectReference;
            PdfAction            action    = PdfAction.Rendition(clipTitle, fs, mimeType, refi);
            PdfIndirectReference actionRef = writer.AddToBody(action).IndirectReference;

            // for play on display add trigger event
            if (playOnDisplay)
            {
                PdfDictionary aa = new PdfDictionary();
                aa.Put(new PdfName("PV"), actionRef);
                ann.Put(PdfName.AA, aa);
            }
            ann.Put(PdfName.A, actionRef);
            return(ann);
        }
コード例 #6
0
 internal override void AddAnnotation(PdfAnnotation annot)
 {
     ((PdfStamperImp)writer).AddAnnotation(annot, ps.pageN);
 }
コード例 #7
0
 /**
  * Adds an annotation of form field in a specific page. This page number
  * can be overridden with {@link PdfAnnotation#setPlaceInPage(int)}.
  * @param annot the annotation
  * @param page the page
  */
 public void AddAnnotation(PdfAnnotation annot, int page)
 {
     stamper.AddAnnotation(annot, page);
 }
コード例 #8
0
            public void AddAnnotation(PdfAnnotation annot)
            {
                ArrayList allAnnots = new ArrayList();

                if (annot.IsForm())
                {
                    PdfFormField field = (PdfFormField)annot;
                    if (field.Parent != null)
                    {
                        return;
                    }
                    ExpandFields(field, allAnnots);
                    if (cstp.fieldTemplates == null)
                    {
                        cstp.fieldTemplates = new Hashtable();
                    }
                }
                else
                {
                    allAnnots.Add(annot);
                }
                for (int k = 0; k < allAnnots.Count; ++k)
                {
                    annot = (PdfAnnotation)allAnnots[k];
                    if (annot.IsForm())
                    {
                        if (!annot.IsUsed())
                        {
                            Hashtable templates = annot.Templates;
                            if (templates != null)
                            {
                                foreach (object tpl in templates.Keys)
                                {
                                    cstp.fieldTemplates[tpl] = null;
                                }
                            }
                        }
                        PdfFormField field = (PdfFormField)annot;
                        if (field.Parent == null)
                        {
                            AddDocumentField(field.IndirectReference);
                        }
                    }
                    if (annot.IsAnnotation())
                    {
                        PdfObject pdfobj = PdfReader.GetPdfObject(pageN.Get(PdfName.ANNOTS), pageN);
                        PdfArray  annots = null;
                        if (pdfobj == null || !pdfobj.IsArray())
                        {
                            annots = new PdfArray();
                            pageN.Put(PdfName.ANNOTS, annots);
                        }
                        else
                        {
                            annots = (PdfArray)pdfobj;
                        }
                        annots.Add(annot.IndirectReference);
                        if (!annot.IsUsed())
                        {
                            PdfRectangle rect = (PdfRectangle)annot.Get(PdfName.RECT);
                            if (rect != null && (rect.Left != 0 || rect.Right != 0 || rect.Top != 0 || rect.Bottom != 0))
                            {
                                int       rotation = reader.GetPageRotation(pageN);
                                Rectangle pageSize = reader.GetPageSizeWithRotation(pageN);
                                switch (rotation)
                                {
                                case 90:
                                    annot.Put(PdfName.RECT, new PdfRectangle(
                                                  pageSize.Top - rect.Bottom,
                                                  rect.Left,
                                                  pageSize.Top - rect.Top,
                                                  rect.Right));
                                    break;

                                case 180:
                                    annot.Put(PdfName.RECT, new PdfRectangle(
                                                  pageSize.Right - rect.Left,
                                                  pageSize.Top - rect.Bottom,
                                                  pageSize.Right - rect.Right,
                                                  pageSize.Top - rect.Top));
                                    break;

                                case 270:
                                    annot.Put(PdfName.RECT, new PdfRectangle(
                                                  rect.Bottom,
                                                  pageSize.Right - rect.Left,
                                                  rect.Top,
                                                  pageSize.Right - rect.Right));
                                    break;
                                }
                            }
                        }
                    }
                    if (!annot.IsUsed())
                    {
                        annot.SetUsed();
                        cstp.AddToBody(annot, annot.IndirectReference);
                    }
                }
            }
コード例 #9
0
 public override void AddAnnotation(PdfAnnotation annot)
 {
 }
コード例 #10
0
 public static PdfAction CreateHide(PdfAnnotation annot, bool hide)
 {
     return(CreateHide(annot.IndirectReference, hide));
 }