PdfJavaScriptAction : "this.saveAs('/ c / temp / temp.pdf');"
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");
SIGN IN To post a reply.
2 Replies
GR
Gayathri Ramalingam
Syncfusion Team
November 30, 2016 04:43 PM UTC
Hi Vikas,
Thank you for using Syncfusion products.
We will analyze the feasibility to achieve your requirement of “Adding button field in PDF document using Javascript action”. We will update you with the further details on 1st December, 2016.
With Regards,
Gayathri R
GR
Gayathri Ramalingam
Syncfusion Team
December 1, 2016 04:57 PM UTC
Hi Vikas,
We are following Acrobat’s procedure to add action for form fields using Javascript action. After analyzing the issue “Adding button field in PDF document using Javascript action”, there is no support to add save action in button field using Java script action. We have reported the same to acrobat support team. We will update you once we got response from acrobat’s support team.
With Regards,
Gayathri R
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
VJ Vikas Jagtap
- Nov 29, 2016 10:15 PM UTC
- Dec 1, 2016 04:57 PM UTC