示例#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)
     {
         action.Put(PdfName.D, destination.GetPdfObject());
     }
     if (targetDictionary != null)
     {
         action.Put(PdfName.T, targetDictionary.GetPdfObject());
     }
     return(action);
 }
示例#2
0
 /// <summary>Creates a URI action (section 12.6.4.7 of ISO 32000-1).</summary>
 /// <param name="uri">the uniform resource identifier to resolve</param>
 /// <param name="isMap">a flag specifying whether to track the mouse position when the URI is resolved</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateURI(String uri, bool isMap)
 {
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.URI).Put(PdfName.URI, new PdfString(
                                                                                        uri)).Put(PdfName.IsMap, PdfBoolean.ValueOf(isMap)));
 }
示例#3
0
 /// <summary>
 /// If set to true, the text specified by the
 /// <see cref="iText.Kernel.Pdf.PdfName.Contents"/>
 /// or
 /// <see cref="iText.Kernel.Pdf.PdfName.RC"/>
 /// entries
 /// (see
 /// <see cref="PdfAnnotation.GetContents()"/>
 /// and
 /// <see cref="PdfMarkupAnnotation.GetRichText()"/>
 /// )
 /// will be replicated as a caption in the appearance of the line.
 /// </summary>
 /// <param name="contentsAsCaption">true, if the annotation text should be replicated as a caption, false otherwise.
 ///     </param>
 /// <returns>
 /// this
 /// <see cref="PdfLineAnnotation"/>
 /// instance.
 /// </returns>
 public virtual iText.Kernel.Pdf.Annot.PdfLineAnnotation SetContentsAsCaption(bool contentsAsCaption)
 {
     return((iText.Kernel.Pdf.Annot.PdfLineAnnotation)Put(PdfName.Cap, PdfBoolean.ValueOf(contentsAsCaption)));
 }
示例#4
0
 /// <summary>Creates a GoToR action, or remote action (section 12.6.4.3 of ISO 32000-1).</summary>
 /// <param name="fileSpec">the file in which the destination shall be located</param>
 /// <param name="destination">the destination in the remote document to jump to</param>
 /// <param name="newWindow">a flag specifying whether to open the destination document in a new window</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(PdfFileSpec fileSpec, PdfDestination destination
                                                             , bool newWindow)
 {
     return(CreateGoToR(fileSpec, destination).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow)));
 }
示例#5
0
 /// <summary>Creates a Hide action (section 12.6.4.10 of ISO 32000-1).</summary>
 /// <param name="text">
 /// a text string array giving the fully qualified field names of interactive form fields whose
 /// associated widget annotation or annotations are to be affected
 /// </param>
 /// <param name="hidden">a flag indicating whether to hide the annotation (<code>true</code>) or show it (<code>false</code>)
 ///     </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateHide(String[] text, bool hidden)
 {
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.Hide).Put(PdfName.T, GetArrayFromStringList
                                                                                         (text)).Put(PdfName.H, PdfBoolean.ValueOf(hidden)));
 }
示例#6
0
 /// <summary>Sets the initial visibility of the field.</summary>
 /// <param name="visible"/>
 public virtual iText.Kernel.Pdf.Collection.PdfCollectionField SetVisibility(bool visible)
 {
     GetPdfObject().Put(PdfName.V, PdfBoolean.ValueOf(visible));
     return(this);
 }
示例#7
0
 /// <summary>
 /// Sets the text knockout flag, which determine the behaviour of overlapping glyphs
 /// within a text object in the transparent imaging model,
 /// <c>TK</c>
 /// key.
 /// </summary>
 /// <param name="textKnockoutFlag">
 ///
 /// <see langword="true"/>
 /// if enabled.
 /// </param>
 /// <returns>object itself.</returns>
 public virtual iText.Kernel.Pdf.Extgstate.PdfExtGState SetTextKnockoutFlag(bool textKnockoutFlag)
 {
     return(Put(PdfName.TK, PdfBoolean.ValueOf(textKnockoutFlag)));
 }
示例#8
0
 /// <summary>Creates a Hide action (section 12.6.4.10 of ISO 32000-1).</summary>
 /// <param name="annotations">the annotations to be hidden or shown</param>
 /// <param name="hidden">a flag indicating whether to hide the annotation (<code>true</code>) or show it (<code>false</code>)
 ///     </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateHide(PdfAnnotation[] annotations, bool hidden)
 {
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.Hide).Put(PdfName.T, GetPdfArrayFromAnnotationsList
                                                                                         (annotations)).Put(PdfName.H, PdfBoolean.ValueOf(hidden)));
 }
 /// <summary>Sets a flag specifying whether the annotation shall initially be displayed open.</summary>
 /// <remarks>
 /// Sets a flag specifying whether the annotation shall initially be displayed open.
 /// This flag has affect to not all kinds of annotations.
 /// </remarks>
 /// <param name="open">true if annotation shall initially be open, false - if closed.</param>
 /// <returns>
 /// this
 /// <see cref="PdfPopupAnnotation"/>
 /// instance.
 /// </returns>
 public virtual iText.Kernel.Pdf.Annot.PdfPopupAnnotation SetOpen(bool open)
 {
     return((iText.Kernel.Pdf.Annot.PdfPopupAnnotation)Put(PdfName.Open, PdfBoolean.ValueOf(open)));
 }
示例#10
0
 /// <summary>
 /// Sets the alpha source flag ("alpha is shape"), specifying whether the current soft mask and alpha constant
 /// shall be interpreted as shape values (
 /// <see langword="true"/>
 /// ) or opacity values (
 /// <see langword="false"/>
 /// ),
 /// <c>AIS</c>
 /// key.
 /// </summary>
 /// <param name="alphaSourceFlag">
 /// if
 /// <see langword="true"/>
 /// - alpha as shape values, if
 /// <see langword="false"/>
 /// — as opacity values.
 /// </param>
 /// <returns>object itself.</returns>
 public virtual iText.Kernel.Pdf.Extgstate.PdfExtGState SetAlphaSourceFlag(bool alphaSourceFlag)
 {
     return(Put(PdfName.AIS, PdfBoolean.ValueOf(alphaSourceFlag)));
 }
示例#11
0
 private static PdfDictionary CreateDictionaryFromMap(PdfStream stream, IDictionary <String, Object> parms)
 {
     if (parms != null)
     {
         PdfDictionary dictionary = new PdfDictionary();
         foreach (KeyValuePair <String, Object> entry in parms)
         {
             Object value = entry.Value;
             String key   = entry.Key;
             if (value is int?)
             {
                 dictionary.Put(new PdfName(key), new PdfNumber((int)value));
             }
             else
             {
                 if (value is float?)
                 {
                     dictionary.Put(new PdfName(key), new PdfNumber((float)value));
                 }
                 else
                 {
                     if (value is String)
                     {
                         if (value.Equals("Mask"))
                         {
                             dictionary.Put(PdfName.Mask, new PdfLiteral((String)value));
                         }
                         else
                         {
                             String str = (String)value;
                             if (str.IndexOf('/') == 0)
                             {
                                 dictionary.Put(new PdfName(key), new PdfName(str.Substring(1)));
                             }
                             else
                             {
                                 dictionary.Put(new PdfName(key), new PdfString(str));
                             }
                         }
                     }
                     else
                     {
                         if (value is byte[])
                         {
                             //TODO Check inline images
                             PdfStream globalsStream = new PdfStream();
                             globalsStream.GetOutputStream().WriteBytes((byte[])value);
                             dictionary.Put(PdfName.JBIG2Globals, globalsStream);
                         }
                         else
                         {
                             if (value is bool?)
                             {
                                 dictionary.Put(new PdfName(key), PdfBoolean.ValueOf((bool)value));
                             }
                             else
                             {
                                 if (value is Object[])
                                 {
                                     dictionary.Put(new PdfName(key), CreateArray(stream, (Object[])value));
                                 }
                                 else
                                 {
                                     if (value is float[])
                                     {
                                         dictionary.Put(new PdfName(key), new PdfArray((float[])value));
                                     }
                                     else
                                     {
                                         if (value is int[])
                                         {
                                             dictionary.Put(new PdfName(key), new PdfArray((int[])value));
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return(dictionary);
     }
     return(null);
 }
示例#12
0
 public virtual iText.Kernel.Pdf.Annot.Pdf3DAnnotation SetInteractive(bool interactive)
 {
     return((iText.Kernel.Pdf.Annot.Pdf3DAnnotation)Put(PdfName._3DI, PdfBoolean.ValueOf(interactive)));
 }
示例#13
0
 /// <summary>Indication if the field value should be editable in the viewer.</summary>
 /// <param name="editable"/>
 public virtual iText.Kernel.Pdf.Collection.PdfCollectionField SetEditable(bool editable)
 {
     GetPdfObject().Put(PdfName.E, PdfBoolean.ValueOf(editable));
     return(this);
 }
示例#14
0
 /// <summary>Creates a Sound action (section 12.6.4.8 of ISO 32000-1).</summary>
 /// <remarks>Creates a Sound action (section 12.6.4.8 of ISO 32000-1). Deprecated in PDF 2.0.</remarks>
 /// <param name="sound">a sound object defining the sound that shall be played (see section 13.3 of ISO 32000-1)
 ///     </param>
 /// <param name="volume">the volume at which to play the sound, in the range -1.0 to 1.0. Default value: 1.0</param>
 /// <param name="synchronous">
 /// a flag specifying whether to play the sound synchronously or asynchronously.
 /// If this flag is <code>true</code>, the conforming reader retains control, allowing no further user
 /// interaction other than canceling the sound, until the sound has been completely played.
 /// Default value: <code>false</code>
 /// </param>
 /// <param name="repeat">
 /// a flag specifying whether to repeat the sound indefinitely
 /// If this entry is present, the Synchronous entry shall be ignored. Default value: <code>false</code>
 /// </param>
 /// <param name="mix">a flag specifying whether to mix this sound with any other sound already playing</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateSound(PdfStream sound, float volume, bool synchronous
                                                             , bool repeat, bool mix)
 {
     if (volume < -1 || volume > 1)
     {
         throw new ArgumentException("volume");
     }
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.Sound).Put(PdfName.Sound, sound).Put
                (PdfName.Volume, new PdfNumber(volume)).Put(PdfName.Synchronous, PdfBoolean.ValueOf(synchronous)).Put(
                PdfName.Repeat, PdfBoolean.ValueOf(repeat)).Put(PdfName.Mix, PdfBoolean.ValueOf(mix)));
 }
示例#15
0
 /// <summary>
 /// Set overprint flag value for <b>stroking</b> operations,
 /// <c>OP</c>
 /// key.
 /// </summary>
 /// <param name="strokeOverPrintFlag">
 ///
 /// <see langword="true"/>
 /// , for applying overprint for <b>stroking</b> operations.
 /// </param>
 /// <returns>object itself.</returns>
 public virtual iText.Kernel.Pdf.Extgstate.PdfExtGState SetStrokeOverPrintFlag(bool strokeOverPrintFlag)
 {
     return(Put(PdfName.OP, PdfBoolean.ValueOf(strokeOverPrintFlag)));
 }
示例#16
0
 /// <summary>Creates a Hide action (section 12.6.4.10 of ISO 32000-1).</summary>
 /// <param name="annotation">the annotation to be hidden or shown</param>
 /// <param name="hidden">a flag indicating whether to hide the annotation (<code>true</code>) or show it (<code>false</code>)
 ///     </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateHide(PdfAnnotation annotation, bool hidden)
 {
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.Hide).Put(PdfName.T, annotation.GetPdfObject
                                                                                         ()).Put(PdfName.H, PdfBoolean.ValueOf(hidden)));
 }
示例#17
0
 /// <summary>
 /// Set overprint flag value for <b>non-stroking</b> operations,
 /// <c>op</c>
 /// key.
 /// </summary>
 /// <param name="fillOverprintFlag">
 ///
 /// <see langword="true"/>
 /// , for applying overprint for <b>non-stroking</b> operations.
 /// </param>
 /// <returns>object itself.</returns>
 public virtual iText.Kernel.Pdf.Extgstate.PdfExtGState SetFillOverPrintFlag(bool fillOverprintFlag)
 {
     return(Put(PdfName.op, PdfBoolean.ValueOf(fillOverprintFlag)));
 }
示例#18
0
 /// <summary>Creates a Hide action (section 12.6.4.10 of ISO 32000-1).</summary>
 /// <param name="text">
 /// a text string giving the fully qualified field name of an interactive form field whose
 /// associated widget annotation or annotations are to be affected
 /// </param>
 /// <param name="hidden">a flag indicating whether to hide the annotation (<code>true</code>) or show it (<code>false</code>)
 ///     </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateHide(String text, bool hidden)
 {
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.Hide).Put(PdfName.T, new PdfString(text
                                                                                                              )).Put(PdfName.H, PdfBoolean.ValueOf(hidden)));
 }
示例#19
0
 /// <summary>
 /// Sets value of an automatic stroke adjustment flag,
 /// <c>SA</c>
 /// key.
 /// </summary>
 /// <param name="strokeAdjustment">
 /// a
 /// <c>boolean</c>
 /// value.
 /// </param>
 /// <returns>object itself.</returns>
 public virtual iText.Kernel.Pdf.Extgstate.PdfExtGState SetAutomaticStrokeAdjustmentFlag(bool strokeAdjustment
                                                                                         )
 {
     return(Put(PdfName.SA, PdfBoolean.ValueOf(strokeAdjustment)));
 }
示例#20
0
        /// <summary>Creates a Set-OCG-State action (section 12.6.4.12 of ISO 32000-1).</summary>
        /// <param name="states">
        /// states a list of
        /// <see cref="PdfActionOcgState"/>
        /// state descriptions
        /// </param>
        /// <param name="preserveRb">
        /// If true, indicates that radio-button state relationships between optional content groups
        /// should be preserved when the states are applied
        /// </param>
        /// <returns>created action</returns>
        public static iText.Kernel.Pdf.Action.PdfAction CreateSetOcgState(IList <PdfActionOcgState> states, bool preserveRb
                                                                          )
        {
            PdfArray stateArr = new PdfArray();

            foreach (PdfActionOcgState state in states)
            {
                stateArr.AddAll(state.GetObjectList());
            }
            return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.SetOCGState).Put(PdfName.State, stateArr
                                                                                                   ).Put(PdfName.PreserveRB, PdfBoolean.ValueOf(preserveRb)));
        }
示例#21
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);
 }