A little confused about required fields

So I’m building a PDF from scratch, and as part of this I use a few Form Fields. I have set the Field.Required = true; but Acrobat doesn’t seem to validate and require them when saving or printing… Maybe I’m just not understanding how required works? Can someone explain how I can mark a form field as required so that the user must fill the entry in before they save and or print.

Hi John,

Thanks for your inquiry. Please note Required property is used in code to manipulate required fields. However, for validation in GUI you need to implement java script on form fields. Please check following documentation link to set java script on a form field. Hopefully it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,

Okay I have some javascript working on the page (through a button), in order to validate my PDF. Are there any PDF events I can bind to like beforeSave or beforePrint that I can use to enforce my validation. For instance, I don’t want the user to be able to save or print the form without the PDF being valid first.


If someone has a link to Adobe’s most current PDF javascript API docs, that would be extremely helpful.

Okay according to this:

http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_Dev_Contexts.74.5.html

There are document level scripts for the events I need… but I’m not quite sure how to add them using ASPOSE.PDF. Could someone point me to the proper documentation and or an example of how to achieve this.

Okay so this seems to have gotten me pretty close:


Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();
Aspose.Pdf.InteractiveFeatures.JavascriptAction beforeSave = new Aspose.Pdf.InteractiveFeatures.JavascriptAction(“app.alert({ cMsg: ‘Do you want to save this document?’, cTitle: ‘Save?’, nIcon: 2, nType: 2 });”);
pdf.Actions.BeforeSaving = beforeSave;

This will show an alert before saving, but I can’t find any way to cancel the save… I tried:

cancel = true;
return false;
event.rc = false;

none of them seem to cancel the actual save. Does Adobe not supply a way to cancel a save operation?
Xorcist:
Okay so this seems to have gotten me pretty close:

Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();
Aspose.Pdf.InteractiveFeatures.JavascriptAction beforeSave = new Aspose.Pdf.InteractiveFeatures.JavascriptAction("app.alert({ cMsg: 'Do you want to save this document?', cTitle: 'Save?', nIcon: 2, nType: 2 });");
pdf.Actions.BeforeSaving = beforeSave;

This will show an alert before saving, but I can't find any way to cancel the save... I tried:

cancel = true;
return false;
event.rc = false;

none of them seem to cancel the actual save. Does Adobe not supply a way to cancel a save operation?
Hi John,

Thanks for sharing the details.

I have tested the scenario and I am able to notice the same problem. For the sake of correction, I have logged this problem as PDFNEWNET-36656 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Hi John,


Thanks for your patience. We have investigated the issue and found that it is not Aspose.Pdf bug.

Event is successfully added. Alert is shown when document is saved. But in Acrobat Reader specification it is not mentioned that this alert may replace standard Acrobat prompt “Do you want to save changed document”.

We are sorry for the inconvenience caused.

Best Regards,