예제 #1
0
        private void setActionValue(JavaScriptAction action, string key)
        {
            switch (key)
            {
            case "WC":
                _beforeClosing = action;
                break;

            case "WS":
                _beforeSaving = action;
                break;

            case "DS":
                _afterSaving = action;
                break;

            case "WP":
                _beforePrinting = action;
                break;

            case "DP":
                _afterPrinting = action;
                break;
            }
        }
예제 #2
0
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";
            // Add page
            pdfDocument.Pages.Add(new Page(PaperFormat.A4));

            // Add action to document open event
            JavaScriptAction onOpenDocument = new JavaScriptAction("app.alert(\"OnOpenDocument\",3)");

            pdfDocument.OnOpenDocument = onOpenDocument;

            // Add action to document close event
            JavaScriptAction onBeforeClosing = new JavaScriptAction("app.alert(\"OnBeforeClosing\",3)");

            pdfDocument.OnBeforeClosing = onBeforeClosing;

            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open document in default PDF viewer app
            Process.Start("result.pdf");
        }
예제 #3
0
 private void setAdditionalAction(JavaScriptAction action, string key)
 {
     if (action == null)
     {
         setActionValue(null, key);
         if ((_dictionary["AA"] as PDFDictionary) != null)
         {
             (_dictionary["AA"] as PDFDictionary).RemoveItem(key);
             if ((_dictionary["AA"] as PDFDictionary).Count == 0)
             {
                 _dictionary.RemoveItem("AA");
             }
         }
     }
     else
     {
         JavaScriptAction a = (JavaScriptAction)action.Clone(_documentEssential);
         setActionValue(a, key);
         if ((_dictionary["AA"] as PDFDictionary) == null)
         {
             _dictionary.AddItem("AA", new PDFDictionary());
         }
         (_dictionary["AA"] as PDFDictionary).AddItem(key, a.GetDictionary());
     }
 }
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";
            // Add page
            pdfDocument.Pages.Add(new Page(PaperFormat.A4));

            // Add action to document open event
            JavaScriptAction onOpenDocument = new JavaScriptAction("app.alert(\"OnOpenDocument\",3)");

            pdfDocument.OnOpenDocument = onOpenDocument;

            // Add action to document close event
            JavaScriptAction onBeforeClosing = new JavaScriptAction("app.alert(\"OnBeforeClosing\",3)");

            pdfDocument.OnBeforeClosing = onBeforeClosing;

            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
예제 #5
0
 private void setAdditionalAction(JavaScriptAction action, string key)
 {
     if (action == null)
     {
         setActionValue(null, key);
         if (Dictionary["AA"] as PDFDictionary != null)
         {
             (Dictionary["AA"] as PDFDictionary).RemoveItem(key);
             if ((Dictionary["AA"] as PDFDictionary).Count == 0)
             {
                 Dictionary.RemoveItem("AA");
             }
         }
     }
     else
     {
         JavaScriptAction a = (JavaScriptAction)action.Clone(Owner);
         setActionValue(a, key);
         if (Dictionary["AA"] as PDFDictionary == null)
         {
             Dictionary.AddItem("AA", new PDFDictionary());
         }
         (Dictionary["AA"] as PDFDictionary).AddItem(key, a.GetDictionary());
     }
 }
        internal override Action Clone(IDocumentEssential owner)
        {
            PDFDictionary dict = new PDFDictionary();

            dict.AddItem("Type", new PDFName("Action"));
            dict.AddItem("S", new PDFName("JavaScript"));

            IPDFObject js = _dictionary["JS"];

            if (js != null)
            {
                dict.AddItem("JS", js.Clone());
            }

            JavaScriptAction action = new JavaScriptAction(dict, owner);

            IPDFObject next = _dictionary["Next"];

            if (next != null)
            {
                for (int i = 0; i < Next.Count; ++i)
                {
                    action.Next.Add(Next[i]);
                }
            }

            return(action);
        }
예제 #7
0
        private void setActionValue(JavaScriptAction action, string key)
        {
            switch (key)
            {
            case "K":
                _onKeyPressed = action;
                break;

            case "F":
                _onBeforeFormatting = action;
                break;

            case "V":
                _onChange = action;
                break;

            case "C":
                _onOtherFieldChanged = action;
                break;
            }
        }