Exemplo n.º 1
0
 /// <summary>Sets Action element, a child of OnActivation element of the link annotation.</summary>
 /// <remarks>
 /// Sets Action element, a child of OnActivation element of the link annotation.
 /// Corresponds to the A key in the link annotation dictionary.
 /// </remarks>
 public virtual iText.Forms.Xfdf.AnnotObject SetAction(ActionObject action)
 {
     this.action = action;
     return(this);
 }
Exemplo n.º 2
0
        private static void AddActionObject(ActionObject actionObject, XmlElement onActivation, XmlDocument document
                                            )
        {
            //no attributes, children elements URI|Launch|GoTo|GoToR|Named
            XmlElement action = document.CreateElement(XfdfConstants.ACTION);

            if (actionObject.GetUri() != null)
            {
                XmlElement uri = document.CreateElement(XfdfConstants.URI);
                //no children
                //required attribute Name, optional attribute IsMap
                uri.SetAttribute(XfdfConstants.NAME_CAPITAL, actionObject.GetUri().GetValue());
                if (actionObject.IsMap())
                {
                    uri.SetAttribute(XfdfConstants.IS_MAP, "true");
                }
                else
                {
                    uri.SetAttribute(XfdfConstants.IS_MAP, "false");
                }
                action.AppendChild(uri);
            }
            else
            {
                if (PdfName.GoTo.Equals(actionObject.GetType()))
                {
                    XmlElement goTo = document.CreateElement(XfdfConstants.GO_TO);
                    AddDest(actionObject.GetDestination(), goTo, document);
                    action.AppendChild(goTo);
                }
                else
                {
                    if (PdfName.GoToR.Equals(actionObject.GetType()))
                    {
                        XmlElement goToR = document.CreateElement(XfdfConstants.GO_TO_R);
                        if (actionObject.GetDestination() != null)
                        {
                            AddDest(actionObject.GetDestination(), goToR, document);
                        }
                        else
                        {
                            if (actionObject.GetFileOriginalName() != null)
                            {
                                XmlElement file = document.CreateElement(XfdfConstants.FILE);
                                file.SetAttribute(XfdfConstants.ORIGINAL_NAME, actionObject.GetFileOriginalName());
                                goToR.AppendChild(file);
                            }
                            else
                            {
                                logger.Error("Dest or File elements are missing.");
                            }
                        }
                        action.AppendChild(goToR);
                    }
                    else
                    {
                        if (PdfName.Named.Equals(actionObject.GetType()))
                        {
                            XmlElement named = document.CreateElement(XfdfConstants.NAMED);
                            named.SetAttribute(XfdfConstants.NAME_CAPITAL, actionObject.GetNameAction().GetValue());
                            action.AppendChild(named);
                        }
                        else
                        {
                            if (PdfName.Launch.Equals(actionObject.GetType()))
                            {
                                XmlElement launch = document.CreateElement(XfdfConstants.LAUNCH);
                                if (actionObject.GetFileOriginalName() != null)
                                {
                                    XmlElement file = document.CreateElement(XfdfConstants.FILE);
                                    file.SetAttribute(XfdfConstants.ORIGINAL_NAME, actionObject.GetFileOriginalName());
                                    launch.AppendChild(file);
                                }
                                else
                                {
                                    logger.Error("File element is missing");
                                }
                                if (actionObject.IsNewWindow())
                                {
                                    launch.SetAttribute(XfdfConstants.NEW_WINDOW, "true");
                                }
                                action.AppendChild(launch);
                            }
                        }
                    }
                }
            }
            onActivation.AppendChild(action);
        }