Пример #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);
        }
Пример #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);
        }
Пример #3
0
 public void SetAdditionalActions(PdfName key, PdfAction action)
 {
     PdfDictionary dic;
     PdfObject obj = Get(PdfName.AA);
     if (obj != null && obj.IsDictionary())
         dic = (PdfDictionary)obj;
     else
         dic = new PdfDictionary();
     dic.Put(key, action);
     Put(PdfName.AA, dic);
 }
Пример #4
0
 /**
 * Creates a GoTo action to a named destination.
 * @param dest the named destination
 * @param isName if true sets the destination as a name, if false sets it as a String
 * @return a GoToR action
 */
 public static PdfAction GotoLocalPage(String dest, bool isName)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.GOTO);
     if (isName)
         action.Put(PdfName.D, new PdfName(dest));
     else
         action.Put(PdfName.D, new PdfString(dest, null));
     return action;
 }
Пример #5
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 == Legacy.Text.Font.UNDEFINED)
                size = 12;
            baseFont = f.BaseFont;
            BaseFont bf = f.BaseFont;
            int style = f.Style;
            if (style == Legacy.Text.Font.UNDEFINED) {
                style = Legacy.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 & Legacy.Text.Font.BOLD) != 0)
                    attributes[Chunk.TEXTRENDERMODE] = new Object[]{PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null};
                // italic simulation
                if ((style & Legacy.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;
        }
Пример #6
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));
 }
Пример #7
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);
 }
Пример #8
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)
 {
 }
Пример #9
0
 /** When the document opens this <CODE>action</CODE> will be
 * invoked.
 * @param action the action to be invoked
 */
 public virtual void SetOpenAction(PdfAction action)
 {
     pdf.SetOpenAction(action);
 }
Пример #10
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);
 }
Пример #11
0
 /** Creates a GoTo action to an internal page.
  * @param page the page to go. First page is 1
  * @param dest the destination for the page
  * @param writer the writer for this action
  * @return a GoTo action
  */
 public static PdfAction GotoLocalPage(int page, PdfDestination dest, PdfWriter writer)
 {
     PdfIndirectReference piref = writer.GetPageReference(page);
     dest.AddPage(piref);
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.GOTO);
     action.Put(PdfName.D, dest);
     return action;
 }
Пример #12
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));
 }
Пример #13
0
 /**
 * Creates a GoToE action to an embedded file.
 * @param filename   the root document of the target (null if the target is in the same document)
 * @param target a path to the target document of this action
 * @param dest       the destination inside the target document, can be of type PdfDestination, PdfName, or PdfString
 * @param newWindow  if true, the destination document should be opened in a new window
 * @return a GoToE action
 */
 public static PdfAction GotoEmbedded(String filename, PdfTargetDictionary target, PdfObject dest, bool newWindow)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.GOTOE);
     action.Put(PdfName.T, target);
     action.Put(PdfName.D, dest);
     action.Put(PdfName.NEWWINDOW, new PdfBoolean(newWindow));
     if (filename != null) {
         action.Put(PdfName.F, new PdfString(filename));
     }
     return action;
 }
Пример #14
0
 public static PdfAction CreateSubmitForm(string file, Object[] names, int flags)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.SUBMITFORM);
     PdfDictionary dic = new PdfDictionary();
     dic.Put(PdfName.F, new PdfString(file));
     dic.Put(PdfName.FS, PdfName.URL);
     action.Put(PdfName.F, dic);
     if (names != null)
         action.Put(PdfName.FIELDS, BuildArray(names));
     action.Put(PdfName.FLAGS, new PdfNumber(flags));
     return action;
 }
Пример #15
0
 public static PdfAction CreateResetForm(Object[] names, int flags)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.RESETFORM);
     if (names != null)
         action.Put(PdfName.FIELDS, BuildArray(names));
     action.Put(PdfName.FLAGS, new PdfNumber(flags));
     return action;
 }
Пример #16
0
 public static PdfAction CreateImportData(string file)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.IMPORTDATA);
     action.Put(PdfName.F, new PdfString(file));
     return action;
 }
Пример #17
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, Paragraph title, bool open)
     : base()
 {
     StringBuilder buf = new StringBuilder();
     foreach (Chunk chunk in title.Chunks) {
         buf.Append(chunk.Content);
     }
     this.action = action;
     InitOutline(parent, buf.ToString(), open);
 }
Пример #18
0
 /**
 * Use this method to add a JavaScript action at the document level.
 * When the document opens, all this JavaScript runs.
 * @param name The name of the JS Action in the name tree
 * @param js The JavaScript action
 */
 public void AddJavaScript(String name, PdfAction js)
 {
     pdf.AddJavaScript(name, js);
 }
Пример #19
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;
 }
Пример #20
0
 /// <summary>
 /// Sets an action for this Chunk.
 /// </summary>
 /// <param name="action">the action</param>
 /// <returns>this Chunk</returns>
 public Chunk SetAction(PdfAction action)
 {
     return SetAttribute(ACTION, action);
 }
Пример #21
0
 /** Creates a JavaScript action. If the JavaScript is smaller than
  * 50 characters it will be placed as a string, otherwise it will
  * be placed as a compressed stream.
  * @param code the JavaScript code
  * @param writer the writer for this action
  * @param unicode select JavaScript unicode. Note that the internal
  * Acrobat JavaScript engine does not support unicode,
  * so this may or may not work for you
  * @return the JavaScript action
  */
 public static PdfAction JavaScript(string code, PdfWriter writer, bool unicode)
 {
     PdfAction js = new PdfAction();
     js.Put(PdfName.S, PdfName.JAVASCRIPT);
     if (unicode && code.Length < 50) {
         js.Put(PdfName.JS, new PdfString(code, PdfObject.TEXT_UNICODE));
     }
     else if (!unicode && code.Length < 100) {
         js.Put(PdfName.JS, new PdfString(code));
     }
     else {
         try {
             byte[] b = PdfEncodings.ConvertToBytes(code, unicode ? PdfObject.TEXT_UNICODE : PdfObject.TEXT_PDFDOCENCODING);
             PdfStream stream = new PdfStream(b);
             stream.FlateCompress(writer.CompressionLevel);
             js.Put(PdfName.JS, writer.AddToBody(stream).IndirectReference);
         }
         catch {
             js.Put(PdfName.JS, new PdfString(code));
         }
     }
     return js;
 }
Пример #22
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;
 }
Пример #23
0
 /**Creates a Rendition action
 * @param file
 * @param fs
 * @param mimeType
 * @param ref
 * @return a Media Clip action
 * @throws IOException
 */
 public static PdfAction Rendition(String file, PdfFileSpecification fs, String mimeType, PdfIndirectReference refi)
 {
     PdfAction js = new PdfAction();
     js.Put(PdfName.S, PdfName.RENDITION);
     js.Put(PdfName.R, new PdfRendition(file, fs, mimeType));
     js.Put(new PdfName("OP"), new PdfNumber(0));
     js.Put(new PdfName("AN"), refi);
     return js;
 }
Пример #24
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)
 {
 }
Пример #25
0
 /**
 * A set-OCG-state action (PDF 1.5) sets the state of one or more optional content
 * groups.
 * @param state an array consisting of any number of sequences beginning with a <CODE>PdfName</CODE>
 * or <CODE>String</CODE> (ON, OFF, or Toggle) followed by one or more optional content group dictionaries
 * <CODE>PdfLayer</CODE> or a <CODE>PdfIndirectReference</CODE> to a <CODE>PdfLayer</CODE>.<br>
 * The array elements are processed from left to right; each name is applied
 * to the subsequent groups until the next name is encountered:
 * <ul>
 * <li>ON sets the state of subsequent groups to ON</li>
 * <li>OFF sets the state of subsequent groups to OFF</li>
 * <li>Toggle reverses the state of subsequent groups</li>
 * </ul>
 * @param preserveRB if <CODE>true</CODE>, indicates that radio-button state relationships between optional
 * content groups (as specified by the RBGroups entry in the current configuration
 * dictionary) should be preserved when the states in the
 * <CODE>state</CODE> array are applied. That is, if a group is set to ON (either by ON or Toggle) during
 * processing of the <CODE>state</CODE> array, any other groups belong to the same radio-button
 * group are turned OFF. If a group is set to OFF, there is no effect on other groups.<br>
 * If <CODE>false</CODE>, radio-button state relationships, if any, are ignored
 * @return the action
 */
 public static PdfAction SetOCGstate(ArrayList state, bool preserveRB)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.SETOCGSTATE);
     PdfArray a = new PdfArray();
     for (int k = 0; k < state.Count; ++k) {
         Object o = state[k];
         if (o == null)
             continue;
         if (o is PdfIndirectReference)
             a.Add((PdfIndirectReference)o);
         else if (o is PdfLayer)
             a.Add(((PdfLayer)o).Ref);
         else if (o is PdfName)
             a.Add((PdfName)o);
         else if (o is String) {
             PdfName name = null;
             String s = (String)o;
             if (Util.EqualsIgnoreCase(s, "on"))
                 name = PdfName.ON;
             else if (Util.EqualsIgnoreCase(s, "off"))
                 name = PdfName.OFF;
             else if (Util.EqualsIgnoreCase(s, "toggle"))
                 name = PdfName.TOGGLE;
             else
                 throw new ArgumentException("A string '" + s + " was passed in state. Only 'ON', 'OFF' and 'Toggle' are allowed.");
             a.Add(name);
         }
         else
             throw new ArgumentException("Invalid type was passed in state: " + o.GetType().ToString());
     }
     action.Put(PdfName.STATE, a);
     if (!preserveRB)
         action.Put(PdfName.PRESERVERB, PdfBoolean.PDFFALSE);
     return action;
 }
Пример #26
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)
        {
        }
Пример #27
0
 /** Add a chained action.
  * @param na the next action
  */
 public void Next(PdfAction na)
 {
     PdfObject nextAction = Get(PdfName.NEXT);
     if (nextAction == null)
         Put(PdfName.NEXT, na);
     else if (nextAction.IsDictionary()) {
         PdfArray array = new PdfArray(nextAction);
         array.Add(na);
         Put(PdfName.NEXT, array);
     }
     else {
         ((PdfArray)nextAction).Add(na);
     }
 }
Пример #28
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;
        }
Пример #29
0
 internal static PdfAction CreateHide(PdfObject obj, bool hide)
 {
     PdfAction action = new PdfAction();
     action.Put(PdfName.S, PdfName.HIDE);
     action.Put(PdfName.T, obj);
     if (!hide)
         action.Put(PdfName.H, PdfBoolean.PDFFALSE);
     return action;
 }
Пример #30
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;
 }
Пример #31
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 == Legacy.Text.Font.UNDEFINED)
            {
                size = 12;
            }
            baseFont = f.BaseFont;
            BaseFont bf    = f.BaseFont;
            int      style = f.Style;

            if (style == Legacy.Text.Font.UNDEFINED)
            {
                style = Legacy.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 & Legacy.Text.Font.BOLD) != 0)
                {
                    attributes[Chunk.TEXTRENDERMODE] = new Object[] { PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null }
                }
                ;
                // italic simulation
                if ((style & Legacy.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;
            }
        }
Пример #32
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));
        }
Пример #33
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);
 }
Пример #34
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);
        }
Пример #35
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);
 }
Пример #36
0
 //  [C5] named objects: named destinations, javascript, embedded files
 /**
 * Use this method to add a JavaScript action at the document level.
 * When the document opens, all this JavaScript runs.
 * @param js The JavaScript action
 */
 public virtual void AddJavaScript(PdfAction js)
 {
     pdf.AddJavaScript(js);
 }
Пример #37
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
 */
 internal void SetPageAction(PdfName actionType, PdfAction action, int page)
 {
     if (!actionType.Equals(PAGE_OPEN) && !actionType.Equals(PAGE_CLOSE))
         throw new PdfException("Invalid page additional action type: " + actionType.ToString());
     PdfDictionary pg = reader.GetPageN(page);
     PdfDictionary aa = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.AA), pg);
     if (aa == null) {
         aa = new PdfDictionary();
         pg.Put(PdfName.AA, aa);
         MarkUsed(pg);
     }
     aa.Put(actionType, action);
     MarkUsed(aa);
 }
Пример #38
0
 /** Additional-actions defining the actions to be taken in
 * response to various trigger events affecting the document
 * as a whole. The actions types allowed are: <CODE>DOCUMENT_CLOSE</CODE>,
 * <CODE>WILL_SAVE</CODE>, <CODE>DID_SAVE</CODE>, <CODE>WILL_PRINT</CODE>
 * and <CODE>DID_PRINT</CODE>.
 *
 * @param actionType the action type
 * @param action the action to execute in response to the trigger
 * @throws PdfException on invalid action type
 */
 public virtual void SetAdditionalAction(PdfName actionType, PdfAction action)
 {
     if (!(actionType.Equals(DOCUMENT_CLOSE) ||
     actionType.Equals(WILL_SAVE) ||
     actionType.Equals(DID_SAVE) ||
     actionType.Equals(WILL_PRINT) ||
     actionType.Equals(DID_PRINT))) {
         throw new PdfException("Invalid additional action type: " + actionType.ToString());
     }
     pdf.AddAdditionalAction(actionType, action);
 }
Пример #39
0
 /** Additional-actions defining the actions to be taken in
 * response to various trigger events affecting the document
 * as a whole. The actions types allowed are: <CODE>DOCUMENT_CLOSE</CODE>,
 * <CODE>WILL_SAVE</CODE>, <CODE>DID_SAVE</CODE>, <CODE>WILL_PRINT</CODE>
 * and <CODE>DID_PRINT</CODE>.
 *
 * @param actionType the action type
 * @param action the action to execute in response to the trigger
 * @throws PdfException on invalid action type
 */
 public override void SetAdditionalAction(PdfName actionType, PdfAction action)
 {
     if (!(actionType.Equals(DOCUMENT_CLOSE) ||
     actionType.Equals(WILL_SAVE) ||
     actionType.Equals(DID_SAVE) ||
     actionType.Equals(WILL_PRINT) ||
     actionType.Equals(DID_PRINT))) {
         throw new PdfException("Invalid additional action type: " + actionType.ToString());
     }
     PdfDictionary aa = reader.Catalog.GetAsDict(PdfName.AA);
     if (aa == null) {
         if (action == null)
             return;
         aa = new PdfDictionary();
         reader.Catalog.Put(PdfName.AA, aa);
     }
     MarkUsed(aa);
     if (action == null)
         aa.Remove(actionType);
     else
         aa.Put(actionType, action);
 }
Пример #40
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
 * @throws PdfException if the action type is invalid
 */
 public virtual void SetPageAction(PdfName actionType, PdfAction action)
 {
     if (!actionType.Equals(PAGE_OPEN) && !actionType.Equals(PAGE_CLOSE))
         throw new PdfException("Invalid page additional action type: " + actionType.ToString());
     pdf.SetPageAction(actionType, action);
 }
Пример #41
0
 /**
 * @see com.lowagie.text.pdf.PdfWriter#setOpenAction(com.lowagie.text.pdf.PdfAction)
 */
 public override void SetOpenAction(PdfAction action)
 {
     openAction = action;
 }
Пример #42
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);
 }
Пример #43
0
 /** Always throws an <code>UnsupportedOperationException</code>.
 * @param actionType ignore
 * @param action ignore
 * @throws PdfException ignore
 * @see PdfStamper#setPageAction(PdfName, PdfAction, int)
 */
 public override void SetPageAction(PdfName actionType, PdfAction action)
 {
     throw new InvalidOperationException("Use SetPageAction(PdfName actionType, PdfAction action, int page)");
 }