Beispiel #1
0
 /// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary>
 /// <param name="fileSpec">The root document of the target relative to the root document of the source</param>
 /// <param name="destination">the destination in the target to jump to</param>
 /// <param name="newWindow">
 /// if true, the destination document should be opened in a new window;
 /// if false, the destination document should replace the current document in the same window
 /// </param>
 /// <param name="targetDictionary">
 /// A target dictionary specifying path information to the target document.
 /// Each target dictionary specifies one element in the full path to the target and
 /// may have nested target dictionaries specifying additional elements
 /// </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination
                                                             , bool newWindow, PdfTarget targetDictionary)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow));
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     if (destination != null)
     {
         ValidateRemoteDestination(destination);
         action.Put(PdfName.D, destination.GetPdfObject());
     }
     else
     {
         LogManager.GetLogger(typeof(iText.Kernel.Pdf.Action.PdfAction)).Warn(iText.IO.LogMessageConstant.EMBEDDED_GO_TO_DESTINATION_NOT_SPECIFIED
                                                                              );
     }
     if (targetDictionary != null)
     {
         action.Put(PdfName.T, targetDictionary.GetPdfObject());
     }
     return(action);
 }
Beispiel #2
0
 /// <summary>Creates a Launch action (section 12.6.4.5 of ISO 32000-1).</summary>
 /// <param name="fileSpec">the application that shall be launched or the document that shall beopened or printed
 ///     </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateLaunch(PdfFileSpec fileSpec)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            Launch);
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     return(action);
 }
Beispiel #3
0
 /// <summary>Creates a Reset-Form Action (section 12.7.5.3 of ISO 32000-1).</summary>
 /// <param name="names">
 /// an array identifying which fields to reset or which to exclude from resetting,
 /// depending on the setting of the Include/Exclude flag in the Flags entry (see Table 239 of ISO 32000-1).
 /// </param>
 /// <param name="flags">
 /// a set of flags specifying various characteristics of the action (see Table 239 of ISO 32000-1).
 /// Default value to be passed: 0.
 /// </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateResetForm(Object[] names, int flags)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.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);
 }
Beispiel #4
0
 /// <summary>Creates a Movie annotation (section 12.6.4.9 of ISO 32000-1).</summary>
 /// <remarks>Creates a Movie annotation (section 12.6.4.9 of ISO 32000-1). Deprecated in PDF 2.0.</remarks>
 /// <param name="annotation">a movie annotation identifying the movie that shall be played</param>
 /// <param name="title">the title of a movie annotation identifying the movie that shall be played</param>
 /// <param name="operation">
 /// the operation that shall be performed on the movie. Shall be one of the following:
 /// <see cref="iText.Kernel.Pdf.PdfName.Play"/>
 /// ,
 /// <see cref="iText.Kernel.Pdf.PdfName.Stop"/>
 /// ,
 /// <see cref="iText.Kernel.Pdf.PdfName.Pause"/>
 /// ,
 /// <see cref="iText.Kernel.Pdf.PdfName.Resume"/>
 /// </param>
 /// <returns>created annotation</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateMovie(PdfAnnotation annotation, String title, PdfName
                                                             operation)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            Movie).Put(PdfName.T, new PdfString(title)).Put(PdfName.Operation, operation);
     if (annotation != null)
     {
         action.Put(PdfName.Annotation, annotation.GetPdfObject());
     }
     return(action);
 }
Beispiel #5
0
 /// <summary>Creates a Thread action (section 12.6.4.6 of ISO 32000-1).</summary>
 /// <remarks>
 /// Creates a Thread action (section 12.6.4.6 of ISO 32000-1).
 /// A thread action jumps to a specified bead on an article thread (see 12.4.3, "Articles"),
 /// in either the current document or a different one. Table 205 shows the action dictionary
 /// entries specific to this type of action.
 /// </remarks>
 /// <param name="fileSpec">the file containing the thread. If this entry is absent, the thread is in the current file
 ///     </param>
 /// <param name="destinationThread">the destination thread</param>
 /// <param name="bead">the bead in the destination thread</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateThread(PdfFileSpec fileSpec, PdfObject destinationThread
                                                              , PdfObject bead)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            Launch).Put(PdfName.D, destinationThread).Put(PdfName.B, bead);
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     return(action);
 }
Beispiel #6
0
 public static iText.Kernel.Pdf.Action.PdfAction CreateLaunch(PdfFileSpec fileSpec, PdfWin win, bool newWindow
                                                              )
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            Launch).Put(PdfName.NewWindow, new PdfBoolean(newWindow));
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     if (win != null)
     {
         action.Put(PdfName.Win, win.GetPdfObject());
     }
     return(action);
 }
Beispiel #7
0
        /// <summary>Creates a Submit-Form Action (section 12.7.5.2 of ISO 32000-1).</summary>
        /// <param name="file">a uniform resource locator, as described in 7.11.5, "URL Specifications"</param>
        /// <param name="names">
        /// an array identifying which fields to include in the submission or which to exclude,
        /// depending on the setting of the Include/Exclude flag in the Flags entry.
        /// This is an optional parameter and can be <c>null</c>
        /// </param>
        /// <param name="flags">
        /// a set of flags specifying various characteristics of the action (see Table 237 of ISO 32000-1).
        /// Default value to be passed: 0.
        /// </param>
        /// <returns>created action</returns>
        public static iText.Kernel.Pdf.Action.PdfAction CreateSubmitForm(String file, Object[] names, int flags)
        {
            iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction();
            action.Put(PdfName.S, PdfName.SubmitForm);
            PdfDictionary urlFileSpec = new PdfDictionary();

            urlFileSpec.Put(PdfName.F, new PdfString(file));
            urlFileSpec.Put(PdfName.FS, PdfName.URL);
            action.Put(PdfName.F, urlFileSpec);
            if (names != null)
            {
                action.Put(PdfName.Fields, BuildArray(names));
            }
            action.Put(PdfName.Flags, new PdfNumber(flags));
            return(action);
        }
Beispiel #8
0
 /// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary>
 /// <param name="fileSpec">The root document of the target relative to the root document of the source</param>
 /// <param name="destination">the destination in the target to jump to</param>
 /// <param name="newWindow">
 /// if true, the destination document should be opened in a new window;
 /// if false, the destination document should replace the current document in the same window
 /// </param>
 /// <param name="targetDictionary">
 /// A target dictionary specifying path information to the target document.
 /// Each target dictionary specifies one element in the full path to the target and
 /// may have nested target dictionaries specifying additional elements
 /// </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination
                                                             , bool newWindow, PdfTarget targetDictionary)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow));
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     if (destination != null)
     {
         action.Put(PdfName.D, destination.GetPdfObject());
     }
     if (targetDictionary != null)
     {
         action.Put(PdfName.T, targetDictionary.GetPdfObject());
     }
     return(action);
 }
Beispiel #9
0
        /// <summary>Adds a chained action.</summary>
        /// <param name="nextAction">the next action or sequence of actions that shall be performed after the current action
        ///     </param>
        public virtual void Next(iText.Kernel.Pdf.Action.PdfAction nextAction)
        {
            PdfObject currentNextAction = GetPdfObject().Get(PdfName.Next);

            if (currentNextAction == null)
            {
                Put(PdfName.Next, nextAction.GetPdfObject());
            }
            else
            {
                if (currentNextAction.IsDictionary())
                {
                    PdfArray array = new PdfArray(currentNextAction);
                    array.Add(nextAction.GetPdfObject());
                    Put(PdfName.Next, array);
                }
                else
                {
                    ((PdfArray)currentNextAction).Add(nextAction.GetPdfObject());
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Adds an additional action to the provided
        /// <see cref="iText.Kernel.Pdf.PdfObjectWrapper{T}"/>
        /// &lt;
        /// <see cref="iText.Kernel.Pdf.PdfDictionary"/>
        /// &gt; wrapper.
        /// </summary>
        /// <param name="wrapper">the wrapper to add an additional action to</param>
        /// <param name="key">
        /// a
        /// <see cref="iText.Kernel.Pdf.PdfName"/>
        /// specifying the name of an additional action
        /// </param>
        /// <param name="action">
        /// the
        /// <see cref="PdfAction"/>
        /// to add as an additional action
        /// </param>
        public static void SetAdditionalAction(PdfObjectWrapper <PdfDictionary> wrapper, PdfName key, iText.Kernel.Pdf.Action.PdfAction
                                               action)
        {
            PdfDictionary dic;
            PdfObject     obj      = wrapper.GetPdfObject().Get(PdfName.AA);
            bool          aaExists = obj != null && obj.IsDictionary();

            if (aaExists)
            {
                dic = (PdfDictionary)obj;
            }
            else
            {
                dic = new PdfDictionary();
            }
            dic.Put(key, action.GetPdfObject());
            dic.SetModified();
            wrapper.GetPdfObject().Put(PdfName.AA, dic);
            if (!aaExists || !dic.IsIndirect())
            {
                wrapper.GetPdfObject().SetModified();
            }
        }
Beispiel #11
0
        public static void SetAdditionalAction(PdfObjectWrapper <PdfDictionary> wrapper, PdfName key, iText.Kernel.Pdf.Action.PdfAction
                                               action)
        {
            PdfDictionary dic;
            PdfObject     obj = wrapper.GetPdfObject().Get(PdfName.AA);

            if (obj != null && obj.IsDictionary())
            {
                dic = (PdfDictionary)obj;
            }
            else
            {
                dic = new PdfDictionary();
            }
            dic.Put(key, action.GetPdfObject());
            wrapper.GetPdfObject().Put(PdfName.AA, dic);
        }