Example #1
0
        /**
         * Creates a GoToR action to a named destination.
         * @param filename the file name to go to
         * @param dest the destination name
         * @param isName if true sets the destination as a name, if false sets it as a String
         * @param newWindow open the document in a new window if <CODE>true</CODE>, if false the current document is replaced by the new document.
         * @return a GoToR action
         */
        public static PdfAction GotoRemotePage(String filename, String dest, bool isName, bool newWindow)
        {
            PdfAction action = new PdfAction();

            action.Put(PdfName.F, new PdfString(filename));
            action.Put(PdfName.S, PdfName.GOTOR);
            if (isName)
            {
                action.Put(PdfName.D, new PdfName(dest));
            }
            else
            {
                action.Put(PdfName.D, new PdfString(dest, null));
            }
            if (newWindow)
            {
                action.Put(PdfName.NEWWINDOW, PdfBoolean.PDFTRUE);
            }
            return(action);
        }
Example #2
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);
        }
Example #3
0
 /**
  * Sets the field value as a <CODE>PDFAction</CODE>.
  * For example, this method allows setting a form submit button action using {@link PdfAction#createSubmitForm(String, Object[], int)}.
  * This method creates an <CODE>A</CODE> entry for the specified field in the underlying FDF file.
  * Method contributed by Philippe Laflamme (plaflamme)
  * @param field the fully qualified field name
  * @param action the field's action
  * @return <CODE>true</CODE> if the value was inserted,
  * <CODE>false</CODE> if the name is incompatible with
  * an existing field
  * @since	2.1.5
  */
 public bool SetFieldAsAction(String field, PdfAction action)
 {
     return(SetField(field, action));
 }
Example #4
0
        /**
         * Constructs a <CODE>PdfChunk</CODE>-object.
         *
         * @param chunk the original <CODE>Chunk</CODE>-object
         * @param action the <CODE>PdfAction</CODE> if the <CODE>Chunk</CODE> comes from an <CODE>Anchor</CODE>
         */

        internal PdfChunk(Chunk chunk, PdfAction action)
        {
            thisChunk[0] = this;
            value        = chunk.Content;

            Font  f    = chunk.Font;
            float size = f.Size;

            if (size == dpaItextSharp.text.Font.UNDEFINED)
            {
                size = 12;
            }
            baseFont = f.BaseFont;
            BaseFont bf    = f.BaseFont;
            int      style = f.Style;

            if (style == dpaItextSharp.text.Font.UNDEFINED)
            {
                style = dpaItextSharp.text.Font.NORMAL;
            }
            if (baseFont == null)
            {
                // translation of the font-family to a PDF font-family
                baseFont = f.GetCalculatedBaseFont(false);
            }
            else
            {
                // bold simulation
                if ((style & dpaItextSharp.text.Font.BOLD) != 0)
                {
                    attributes[Chunk.TEXTRENDERMODE] = new Object[] { PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null }
                }
                ;
                // italic simulation
                if ((style & dpaItextSharp.text.Font.ITALIC) != 0)
                {
                    attributes[Chunk.SKEW] = new float[] { 0, ITALIC_ANGLE }
                }
                ;
            }
            font = new PdfFont(baseFont, size);
            // other style possibilities
            Hashtable attr = chunk.Attributes;

            if (attr != null)
            {
                foreach (DictionaryEntry entry in attr)
                {
                    string name = (string)entry.Key;
                    if (keysAttributes.ContainsKey(name))
                    {
                        attributes[name] = entry.Value;
                    }
                    else if (keysNoStroke.ContainsKey(name))
                    {
                        noStroke[name] = entry.Value;
                    }
                }
                if ("".Equals(attr[Chunk.GENERICTAG]))
                {
                    attributes[Chunk.GENERICTAG] = chunk.Content;
                }
            }
            if (f.IsUnderlined())
            {
                Object[]   obj    = { null, new float[] { 0, 1f / 15, 0, -1f / 3, 0 } };
                Object[][] unders = Utilities.AddToArray((Object[][])attributes[Chunk.UNDERLINE], obj);
                attributes[Chunk.UNDERLINE] = unders;
            }
            if (f.IsStrikethru())
            {
                Object[]   obj    = { null, new float[] { 0, 1f / 15, 0, 1f / 3, 0 } };
                Object[][] unders = Utilities.AddToArray((Object[][])attributes[Chunk.UNDERLINE], obj);
                attributes[Chunk.UNDERLINE] = unders;
            }
            if (action != null)
            {
                attributes[Chunk.ACTION] = action;
            }
            // the color can't be stored in a PdfFont
            noStroke[Chunk.COLOR]    = f.Color;
            noStroke[Chunk.ENCODING] = font.Font.Encoding;
            Object[] obj2 = (Object[])attributes[Chunk.IMAGE];
            if (obj2 == null)
            {
                image = null;
            }
            else
            {
                attributes.Remove(Chunk.HSCALE); // images are scaled in other ways
                image         = (Image)obj2[0];
                offsetX       = ((float)obj2[1]);
                offsetY       = ((float)obj2[2]);
                changeLeading = (bool)obj2[3];
            }
            font.Image = image;
            object hs = attributes[Chunk.HSCALE];

            if (hs != null)
            {
                font.HorizontalScaling = (float)hs;
            }
            encoding       = font.Font.Encoding;
            splitCharacter = (ISplitCharacter)noStroke[Chunk.SPLITCHARACTER];
            if (splitCharacter == null)
            {
                splitCharacter = DefaultSplitCharacter.DEFAULT;
            }
        }
Example #5
0
 public override void SetAction(PdfAction action, float llx, float lly, float urx, float ury)
 {
     ((PdfStamperImp)writer).AddAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, action), ps.pageN);
 }
Example #6
0
 /**
  * Sets the open and close page additional action.
  * @param actionType the action type. It can be <CODE>PdfWriter.PAGE_OPEN</CODE>
  * or <CODE>PdfWriter.PAGE_CLOSE</CODE>
  * @param action the action to perform
  * @param page the page where the action will be applied. The first page is 1
  * @throws PdfException if the action type is invalid
  */
 public void SetPageAction(PdfName actionType, PdfAction action, int page)
 {
     stamper.SetPageAction(actionType, action, page);
 }
Example #7
0
        public static PdfAnnotation CreateLink(PdfWriter writer, Rectangle rect, PdfName highlight, PdfAction action)
        {
            PdfAnnotation annot = CreateLink(writer, rect, highlight);

            annot.PutEx(PdfName.A, action);
            return(annot);
        }
Example #8
0
        /**
         * Constructs a new <CODE>PdfAnnotation</CODE> of subtype link (Action).
         */

        public PdfAnnotation(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action)
        {
            this.writer = writer;
            Put(PdfName.SUBTYPE, PdfName.LINK);
            Put(PdfName.RECT, new PdfRectangle(llx, lly, urx, ury));
            Put(PdfName.A, action);
            Put(PdfName.BORDER, new PdfBorderArray(0, 0, 0));
            Put(PdfName.C, new PdfColor(0x00, 0x00, 0xFF));
        }
Example #9
0
        /**
         * Constructs a new <CODE>PdfAnnotation</CODE> of subtype link (Action).
         */

        public PdfFormField(PdfWriter writer, float llx, float lly, float urx, float ury, PdfAction action) : base(writer, llx, lly, urx, ury, action)
        {
            Put(PdfName.TYPE, PdfName.ANNOT);
            Put(PdfName.SUBTYPE, PdfName.WIDGET);
            annotation = true;
        }
Example #10
0
        /**
         * Constructs a <CODE>PdfOutline</CODE>.
         * <P>
         * This is the constructor for an <CODE>outline entry</CODE>. The open mode is
         * <CODE>true</CODE>.
         *
         * @param parent the parent of this outline item
         * @param action the <CODE>PdfAction</CODE> for this outline item
         * @param title the title of this outline item
         */

        public PdfOutline(PdfOutline parent, PdfAction action, Paragraph title) : this(parent, action, title, true)
        {
        }
Example #11
0
 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>.
  *
  * @param parent the parent of this outline item
  * @param action the <CODE>PdfAction</CODE> for this outline item
  * @param title the title of this outline item
  * @param open <CODE>true</CODE> if the children are visible
  */
 public PdfOutline(PdfOutline parent, PdfAction action, PdfString title, bool open) : this(parent, action, title.ToString(), open)
 {
 }
Example #12
0
 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>. The open mode is
  * <CODE>true</CODE>.
  *
  * @param parent the parent of this outline item
  * @param action the <CODE>PdfAction</CODE> for this outline item
  * @param title the title of this outline item
  */
 public PdfOutline(PdfOutline parent, PdfAction action, PdfString title) : this(parent, action, title, true)
 {
 }
Example #13
0
 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>.
  *
  * @param parent the parent of this outline item
  * @param action the <CODE>PdfAction</CODE> for this outline item
  * @param title the title of this outline item
  * @param open <CODE>true</CODE> if the children are visible
  */
 public PdfOutline(PdfOutline parent, PdfAction action, string title, bool open) : base()
 {
     this.action = action;
     InitOutline(parent, title, open);
 }