Ejemplo n.º 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);
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public static PdfAnnotation CreateSquareCircle(PdfWriter writer, Rectangle rect, string contents, bool square)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     if (square)
         annot.Put(PdfName.SUBTYPE, PdfName.SQUARE);
     else
         annot.Put(PdfName.SUBTYPE, PdfName.CIRCLE);
     annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     return annot;
 }
Ejemplo n.º 7
0
 internal override void AddAnnotation(PdfAnnotation annot)
 {
     ((PdfStamperImp)writer).AddAnnotation(annot, ps.pageN);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets a generic annotation to this Chunk.
 /// </summary>
 /// <param name="annotation">the annotation</param>
 /// <returns>this Chunk</returns>
 public Chunk SetAnnotation(PdfAnnotation annotation)
 {
     return SetAttribute(PDFANNOTATION, annotation);
 }
Ejemplo n.º 9
0
 public void AddAnnotation(PdfAnnotation annot)
 {
     if (annot.IsForm()) {
         PdfFormField field = (PdfFormField)annot;
         if (field.Parent == null)
             AddFormFieldRaw(field);
     }
     else
         annotations.Add(annot);
 }
Ejemplo n.º 10
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);
                    }
                }
            }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
0
 /** Creates a file attachment annotation
 * @param writer
 * @param rect
 * @param contents
 * @param fs
 * @return the annotation
 * @throws IOException
 */
 public static PdfAnnotation CreateFileAttachment(PdfWriter writer, Rectangle rect, String contents, PdfFileSpecification fs)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.FILEATTACHMENT);
     if (contents != null)
         annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     annot.Put(PdfName.FS, fs.Reference);
     return annot;
 }
Ejemplo n.º 14
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);
         }
     }
 }
Ejemplo n.º 15
0
 public override void AddAnnotation(PdfAnnotation annot)
 {
 }
Ejemplo n.º 16
0
 internal override void AddAnnotation(PdfAnnotation annot, int page)
 {
     annot.Page = page;
     AddAnnotation(annot, reader.GetPageN(page));
 }
Ejemplo n.º 17
0
 /**
 * @see com.lowagie.text.pdf.PdfWriter#addAnnotation(com.lowagie.text.pdf.PdfAnnotation)
 */
 public override void AddAnnotation(PdfAnnotation annot)
 {
     throw new Exception("Unsupported in this context. Use PdfStamper.AddAnnotation()");
 }
Ejemplo n.º 18
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);
 }
Ejemplo n.º 19
0
 public static PdfAction CreateHide(PdfAnnotation annot, bool hide)
 {
     return CreateHide(annot.IndirectReference, hide);
 }
Ejemplo n.º 20
0
 public static PdfAnnotation CreateStamp(PdfWriter writer, Rectangle rect, string contents, string name)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.STAMP);
     annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     annot.Put(PdfName.NAME, new PdfName(name));
     return annot;
 }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
0
 public static PdfAnnotation CreateFreeText(PdfWriter writer, Rectangle rect, string contents, PdfContentByte defaultAppearance)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.FREETEXT);
     annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     annot.DefaultAppearanceString = defaultAppearance;
     return annot;
 }
Ejemplo n.º 23
0
 protected static PdfAnnotation CreateLink(PdfWriter writer, Rectangle rect, PdfName highlight)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.LINK);
     if (!highlight.Equals(HIGHLIGHT_INVERT))
         annot.Put(PdfName.H, highlight);
     return annot;
 }
Ejemplo n.º 24
0
 internal override void AddAnnotation(PdfAnnotation annot)
 {
     ((PdfStamperImp)writer).AddAnnotation(annot, ps.pageN);
 }
Ejemplo n.º 25
0
 /** Adds a <CODE>PdfAnnotation</CODE> or a <CODE>PdfFormField</CODE>
 * to the document. Only the top parent of a <CODE>PdfFormField</CODE>
 * needs to be added.
 * @param annot the <CODE>PdfAnnotation</CODE> or the <CODE>PdfFormField</CODE> to add
 */
 public virtual void AddAnnotation(PdfAnnotation annot)
 {
     pdf.AddAnnotation(annot);
 }
Ejemplo n.º 26
0
 public override void AddAnnotation(PdfAnnotation annot)
 {
 }
Ejemplo n.º 27
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;
 }
Ejemplo n.º 28
0
 public static PdfAction CreateHide(PdfAnnotation annot, bool hide)
 {
     return(CreateHide(annot.IndirectReference, hide));
 }
Ejemplo n.º 29
0
 public static PdfAnnotation CreateLine(PdfWriter writer, Rectangle rect, string contents, float x1, float y1, float x2, float y2)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.LINE);
     annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     PdfArray array = new PdfArray(new PdfNumber(x1));
     array.Add(new PdfNumber(y1));
     array.Add(new PdfNumber(x2));
     array.Add(new PdfNumber(y2));
     annot.Put(PdfName.L, array);
     return annot;
 }
Ejemplo n.º 30
0
 public static PdfAnnotation CreateMarkup(PdfWriter writer, Rectangle rect, string contents, int type, float[] quadPoints)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     PdfName name = PdfName.HIGHLIGHT;
     switch (type) {
         case MARKUP_UNDERLINE:
             name = PdfName.UNDERLINE;
             break;
         case MARKUP_STRIKEOUT:
             name = PdfName.STRIKEOUT;
             break;
         case MARKUP_SQUIGGLY:
             name = PdfName.SQUIGGLY;
             break;
     }
     annot.Put(PdfName.SUBTYPE, name);
     annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     PdfArray array = new PdfArray();
     for (int k = 0; k < quadPoints.Length; ++k)
         array.Add(new PdfNumber(quadPoints[k]));
     annot.Put(PdfName.QUADPOINTS, array);
     return annot;
 }
Ejemplo n.º 31
0
 internal virtual void AddAnnotation(PdfAnnotation annot, int page)
 {
     AddAnnotation(annot);
 }
Ejemplo n.º 32
0
 public static PdfAnnotation CreatePopup(PdfWriter writer, Rectangle rect, string contents, bool open)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.POPUP);
     if (contents != null)
         annot.Put(PdfName.CONTENTS, new PdfString(contents, PdfObject.TEXT_UNICODE));
     if (open)
         annot.Put(PdfName.OPEN, PdfBoolean.PDFTRUE);
     return annot;
 }
Ejemplo n.º 33
0
 public void AddPlainAnnotation(PdfAnnotation annot)
 {
     annotations.Add(annot);
 }
Ejemplo n.º 34
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;
 }
Ejemplo n.º 35
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);
 }
Ejemplo n.º 36
0
 internal void AddAnnotation(PdfAnnotation annot)
 {
     pageEmpty = false;
     annotationsImp.AddAnnotation(annot);
 }