We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Performing click on PDF Form

Hi

I'm trying to do a perform click action on a button which is added to a PDF Form.

I've searched Online Documentation, also tried this approach:

//load document
PdfLoadedDocument doc = new PdfLoadedDocument(_pdfLoadPath);

if (doc.Form.Fields[index] is PdfLoadedButtonField)
{
PdfLoadedButtonField btn = (PdfLoadedButtonField)doc.Form.Fields[i];
btn.
}

Unfortunately button object (btn) does not contain any method which would allow me to perform click on this button.

Is there a way to do this?

With regards,
Lukasz


14 Replies

BP Bhuvaneswari P Syncfusion Team January 12, 2009 04:34 PM UTC

Hi Lukasz,

Thank you for your interest in Syncfusion products.

We are working on this issue and will update the details by tomorrow.

Best Regards,
Bhuvana



LD Lukasz Dejneka January 12, 2009 04:53 PM UTC

Thank you.

I should maybe mention that the buttons are not the only fields on PDF Form that should be clickable. For example checkboxes.

I will attach a form that has some fields that are until clicked "fogged". This I can resolve more easily, just by flattening fields.

But! Form also has calculated fields that are triggered by click (above mentioned checkboxes) and other event similar to control losing focus (textbox from "amount" table). Those events also should be reproducible in SyncFusion libraries.

With regards,
Lukasz



newformform_9c96f7ed.zip


BP Bhuvaneswari P Syncfusion Team January 13, 2009 08:25 AM UTC

Hi Lukasz,

Thanks for the update.

yes, it is possible to raise the events for the form fields using Essential PDF. Please use the Fields Action property to raise the desired events and it will call the Jave script method to perform the actions. For creating the new fields we have the events like GotFocus, LostFocus, Keypress, MousePressed and etc.. But for the existing document fields we can raise only the Mouse events. Please refers to the below code snippet to do so:


//Add action to the new form fields:
PdfTextBoxField textbox = new PdfTextBoxField(page, "text");
textbox.Text = " Test ";
textbox.ToolTip = "Button Tooltip";
textbox.Bounds = new RectangleF(100, 20, 40, 20);
textbox.Actions.MouseLeave = ButMosueLeave();
textbox.Actions.GotFocus = ButMosueLeave();


PdfCheckBoxField check= new PdfCheckBoxField(page, "check");
check.Checked = true;
check.ToolTip = "Button Tooltip";
check.Bounds = new RectangleF(200, 20, 40, 20);
check.Actions.MouseLeave = ButMosueLeave();

document.Form.Fields.Add(textbox);
document.Form.Fields.Add(check);
//Script
public PdfJavaScriptAction ButMosueLeave()
{
string sd = "app.alert('Test',2);";
PdfJavaScriptAction javaAction = new PdfJavaScriptAction(sd);
return (javaAction);
}

//For setting to the existing form fields:
PdfLoadedDocument doc = new PdfLoadedDocument("sample.pdf");
PdfLoadedTextBoxField field = doc.Form.Fields[0] as PdfLoadedTextBoxField;
field.MouseEnter = ButMosueLeave();
doc.Save("sample1.pdf");
System.Diagnostics.Process.Start("Sample1.pdf");



Please refers to the below samples to do so:
http://websamples.syncfusion.com/samples/pdf.Windows/F78897_1/main.htm

Please try these and let us know if this helps you.

Best Regards,
Bhuvana




LD Lukasz Dejneka January 14, 2009 12:09 PM UTC

Hi

Thank you for the reply, but the code you provided does compile with errors.

I should note at this point that I do not create any PDFs, but need to automate PDF Form filling, which will be recieved from various sources.

My code snippet:

...
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Interactive;
...
//load document
PdfLoadedDocument doc = new PdfLoadedDocument(_pdfLoadPath);
//load form
PdfLoadedForm form = doc.Form;
if (doc.Form.Fields[fieldIndex] is PdfLoadedButtonField)
{
PdfLoadedTextBoxField field = doc.Form.Fields[0] as PdfLoadedTextBoxField;
field.MouseEnter = ButMouseLeave();

doc.Close(true);
}
...

Error I get:
'Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField' does not contain a definition for 'MouseEnter' and no extension method 'MouseEnter' accepting a first argument of type 'Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField' could be found (are you missing a using directive or an assembly reference?)

I've added Syncfusion.Core, Syncfusion.Compression.Base & Syncfusion.Pdf.Base references to my project.

I've tried adding other Syncfusion.Pdf.* references and adding them to "using" list with no difference to the error showing.

The example provided in last message contains only example of creating fields, not executing an action on Loaded field.

What am I missing?


With regards,
Lukasz



BP Bhuvaneswari P Syncfusion Team January 15, 2009 09:11 AM UTC

Hi Lukasz,

Thanks for the details.

These events, Gotfocus and LostFocus are included only in our latest version 2009 Volume1 release. We are recommended you to download our latest version 2009 Volmue1 RC from below forum thread:
http://www.syncfusion.com/support/forums/message.aspx?MessageID=78966

Please let me know if you face any issues in the latest version.

Best Regards,
Bhuvana





LD Lukasz Dejneka January 15, 2009 01:41 PM UTC

Hi

Thank you for the reply.

Indeed the code now compiles correctly.

But it does not do what I want to perform - it allows me to set or read a javascript action to the form. And when I open the PDF form this action is triggered for example when I move mouse over a field. But I need to do it myself - manually.

This is not what I need to do.

I have a PDF form, created by someone else, unknown to me. I do not know what scripts are connected to its fields. I need to open this PDF form in computer memory, modify fields, and perform a click on a button/field/whatever. I need automate it, without any user input other than starting whole process.

Is it possible to simulate a mouse click to a form field which is loaded using SyncFusion library?

With regards,
Lukasz



BP Bhuvaneswari P Syncfusion Team January 16, 2009 09:23 AM UTC

Hi Lukasz,

Thanks for the details.

Initially you have requested events for form fields, from your last update I could see that you wanted to fill the form fields. I am not sure your exact requirement. If your intention is form filling then please refers to the below sample browser sample to fill the form fields.

\My Documents\Syncfusion\EssentialStudio\x.x.x.x\Windows\Pdf.Windows\Samples\2.0\Modify Documents\FormFilling\CS

Please let me know if this helps you, if not please let us know while clicking the PDF form button you want to fill all the other fields value or please let me know some more details.

Best Regards,
Bhuvana




LD Lukasz Dejneka January 16, 2009 11:27 AM UTC

Hi

I know how to fill form fields.

I know that you can attach javascript actions to forms.

I'm asking on how to simulate user action (click of a button, click on a checkbox, leaving form field) using Syncfusion.

Please take a look at attached form.

There you have a full set of different fields. But those fields on many occasions have actions atatched on them, when you click them or when they loose focus.

Please take a look at the first table, you can insert amounts of purchased products. If I do it manually the final price is automatically calculated. If I use Syncfusion I fill the Amount field, but nothing is automatically calculated.

Please take a look at "Discount category" checkboxes. If I click on one of them, discount is automatically calculated in another field. If I use Syncfusion to check the checkbox, there is no autocalculation.

I need to be able to trigger the events which launch those automatic scripts contained in PDF form.

With regards,
Lukasz



newformform_a15b5b2d.zip


BP Bhuvaneswari P Syncfusion Team January 19, 2009 01:19 PM UTC

Hi Lukasz,

Thanks for the details.

I am able to understand your requirement. However, it is not possible to execute the Script while filling the form fields using the application. It will be executed only after opened in Acrobat. If you want to execute those scripts, it should be possible by calling in the document load event. But we don't have support for this document load event in our PDFLoadedDocument.

Please let me know if you have any other questions.

Best Regards,
Bhuvana




LD Lukasz Dejneka January 19, 2009 02:22 PM UTC

Hi,

Thank you for the information.

Are you planning of adding some kind of control over scripts attached to pdf forms and fields to SyncFusion in any forseeable future?

This is a major problem at least for us. Some autocalculated fields are easy to reverse engineer, but some scripts can be very complicated (provision calculation, profit margins, etc..). I any case it adds a lot of work when automating such forms.

With regards,
Lukasz





BP Bhuvaneswari P Syncfusion Team January 20, 2009 12:49 PM UTC

Hi Lukasz,

Currently it is not possible to implement such feature. However, we have forward to our development team and will update you the feasible solution within two days time frame.

Best Regards,
Bhuvana



LD Lukasz Dejneka January 26, 2009 08:23 AM UTC

Hi

Any news from developers? Thanks.


With regards,

Lukasz



BP Bhuvaneswari P Syncfusion Team January 27, 2009 12:31 PM UTC

Hi Lukasz,

Sorry for the delay in getting back to you.

Our developers are currently working on this issue and we will get back to you on or before Feb 13th with more details regarding this issue.

Thank you for your co-operation.

Best Regards,
Bhuvana





BP Bhuvaneswari P Syncfusion Team February 18, 2009 06:27 AM UTC

Hi Lukasz,

I apologies for the delay in getting back to you.

Unfortunately we are unable to fix or workaround this issue. Due to the entire calculation is done through the various sub calculations and calculation is based on various field types (text field, choice field, radio button field). And these calculations are done through the JavaScript. So it’s not possible to validate [for the existing forms with Javascript validation] the field’s value when editing the fields through Essential PDF.

Sorry for the inconvenience. Please let me know if you need any further details.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon