VBA add Javascript to Adobe Field & Set Date Format? - javascript

Good afternoon,
I have an excel vba being run when a button is clicked to print to PDF. the script then opens the PDF, add's two signature boxes and two form fields (text).
My two part question is
how do i format the PDF form field i created to a date form field? The VBA that creates the PDF text field is as follows.
coords = Array(thlft + 311, thtop - 26, thrt + 242, thebot)
Set formField = JSO.addField("sca_date", "text", 0, coords) '0 = 1st page
formField.textSize = 6
formField.textFont = "Arial"
formField.StrokeColor = JSO.Color.transparent```
I've examined Adobe's JavaScript™ for Acrobat® API Reference. There are references for creationdate and modified date - but not that I could find to format a text field as a date or just put in a date field.
Is it possible to add javascript to the signature fields? What I mean is right now I can manually open that newly created PDF, click on properties for one of the signature boxes - click signed tab. Then select "this script executes when field is signed". Then I put in some js that will enter the date in the date field when signed. and email the PDF out. What I'd rather do is when I click print to PDF - it puts that javascript into the PDF document for me? I hope that makes sense. I realize I can enter a date into the field with VBA but the date of when the form will be signed is not yet known.
For this one I just couldn't find anything. Mostly the results pertain to coding javascript with VBA but not embedding JS with VBA.

Based on the addField documentation,there appears to be no "date"-type form field available - any date field is just a "text"-type field like the one you already have.
look at the "setAction" method for adding script handlers
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf
Maybe also relevant: https://community.adobe.com/t5/acrobat/can-acrobat-auto-populate-a-date-field-upon-digital-signature-of-a-form/td-p/4524073?page=1

Related

Associate and save value in webform from VBA (visual basic for apps)

I'm writting a test code in Javascript on top of the VBA to autofill the spaces of a web form.
The problem is that, I've a searchbox of all contries with their acronym and I can't select the right one in the test.
For example:
.getElementById("DE_MAN_16").Value = "PT" (or
.getElementById("DE_MAN_16").Value = Range("J21"))
.getElementById("DE_MAN_16").Click
.getElementById("DE_MAN_16").Select
DE_MAN_16 is the id of the country field. J21 is the cell in excel where the value PT is stored.
The value PT is not saved and the field remains empty.
Thanks in advance!

How to convert a text line in text box in MS CRM 2011 to hyperlink

I already have code which is given below
var input = document.getElementById("documentlink");
input.style.color = "blue";
input.style.textDecoration = "underline";
input.onclick = function () {
if (Xrm.Page.getAttribute("documentlink").getValue() != null)
window.open(Xrm.Page.getAttribute("documentlink").getValue());
}
but the problem here is I cannot use html DOM since it can become an issue in upgradation as custom code validation tool identifies textDecoration as an issue.
I cannot make that text box format to URL as that gives absolute URL and I am not allowed to change the types of existing fields.
If there is any method to do this then please help.
Yes, There are a lot of ways to accomplish your goal:
You can add ribbon button by clicking on which url would be opened.
You can create your custom html webresource what can store/read information in/from your field and has required formatting. Shortly about development of Html/Js webresources and embedding it to your crm form you can read here - http://a33ik.blogspot.com/2015/03/howto-htmljs-webresources.html

Conditionally fill button in Adobe PDF form

I have created a huge button covering my whole PDF file. I want to fill it in white if the necessary fields in the PDF form are not filled in.(This is to prevent people from skipping required fields. My javascript code is listed below. I have initially filled in the button using Adobe Acrobat Pro, I am then trying to remove the button if the "year" field is completed.
var aNames = ["year"];
var bComplete = true;
var cValue ="";
for(i=0;i<aNames.length;i++){
cValue=this.getField(aNames[i]).value;
if(cValue==this.getField(aNames[i]).defaultValue){
bComplete=false;
}
}
if(bComplete==true){
document.getElementById("Button1").remove();
}else {
app.alert("Please complete form",0,0);
}
This looks very much like influenced by webbrowser JavaScript…
The first issue is the button; if it covers the document, how can you fill the form (or does it cover subsequent pages?).
About the JavaScript, you do not need to create an array of field names, you know the fields directly, so you can address them directly, without having to loop, as in:
if (this.getField("myYear").value != this.getField("myYear").defaultValue)
Of course, if you have a bunch of such fields, it may be an idea to create a document-level array of the field names.
Next, you won't remove the button field, but you simply hide it, as in:
this.getField("myCoverButton").display = display.hidden ;
It might be a good idea to have a look at the Acrobat JavaScript documentation, which is part of the Acrobat SDK, downloadable from the Adobe website.

Autopopulate form input texboxes with javascript

I have this following problem because I don't have expertise in Javascript
I'm testing a Facebook login at
http://goo.gl/3R3owa
After the user is logged in Facebook an alert windows with the birthday and location comes up. So far so good.
Rather than show that window i will like to autopopulate the day, month and year input boxes in that page.
Is there any way to do that?
Here is my code
http://goo.gl/IFhJdu
Thanks in advance!
Assuming that you have all the data in the response object and element_id# is a valid id of an element present on the HTML page. You can simply use following JS code do set the value of an input field in JS:
document.getElementById('element_id1').value = response.gender;
document.getElementById('element_id2').value = response.birthday;
document.getElementById('element_id3').value = response.location.name;
Similarly, for feeding the data to an HTML element, you can use innerHTML, for example:
document.getElementById('element_id1').innerHTML= response.gender;
(You can use the above code to replace the alert() method in you JS code.)

JavaScript: Parse and Paste Text from Clipboard to PDF document

I've got an PDF document with 2 editable text fields: "surname" and "email".
Now the Email ALWAYS consists of this format: Name.Surname#email.com . So I can simply copy the email and I already have got the data I need in the memory/clipboard.
Now I need JavaScript to do 2 things:
1) Copy the email into the "email" field on Open-Document event.
2) Parse the Name.Surname#email.com and only copy the Surname into the "surname" text field
Before the PDF document is opened, the Name.Surname#mail.com already has been copied to the memory. Now when I open the PDF document, I want both things 1) 2) done.
How do I go about this please?
Create onchange handler and parse input data by regexp. Then manually update fields.

Categories