Below is my code where I am trying to add a Save button inside a pdf, I am attaching a JavaScript Action to it which basically saves the document with a new name.
However the button click is not saving the document. Please see below my code. If I add a simple alert, it works fine.
string fileName = "";
PdfDocument document = new PdfDocument();
document.PageSettings = new PdfPageSettings(new SizeF(300, 400));
PdfPage page = document.Pages.Add();
PdfGraphics graphics = page.Graphics;
PdfImage image = PdfImage.FromStream(new MemoryStream(attachment.FILE_DATA));//PdfImage.FromFile(@"C:\\DevelopmentMobile\\action.png");
PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 8f, PdfFontStyle.Bold);
PdfForm frm = new PdfForm();
graphics.DrawImage(image, 0, 0);
PdfButtonField submitButton = new PdfButtonField(page, "submitButton");
submitButton.Bounds = new RectangleF(25, 160, 100, 20);
submitButton.Text = "Apply";
submitButton.BackColor = new PdfColor(181, 191, 203);
//Create a new PdfJavaScriptAction
PdfJavaScriptAction javaAction = new PdfJavaScriptAction("this.saveAs(\" / c / temp / temp.pdf\");");
//Set the javaAction to submitButton
submitButton.Actions.MouseDown = javaAction;
//Add the submit button to the new document.
document.Form.Fields.Add(submitButton);
fileName = attachment.FILE_NAME.ToString().Replace(Path.GetExtension(attachment.FILE_NAME.ToString()), "");
document.Save(@"C:\\DevelopmentMobile\\" + fileName + "_" + VZUserProfile.Instance.Username.ToString() + ".pdf");
System.Diagnostics.Process.Start(@"C:\\DevelopmentMobile\\" + fileName + "_" + VZUserProfile.Instance.Username.ToString() + ".pdf");