Javascript works in Adobe Reader but not in Nitropdf - javascript

I have setup an interactive PDF form with a Javascript button to submit the form by email, extracting data input by the user. The button works fine in Adobe Reader but does nothing in NitroPDF. Is there a problem with the code (see below)?
var cToAddr = this.getField("ComboBox1").value
var cSubLine = "Property Transaction Form " + this.getField("Text1").value
var cBody = "The attached file is the filled-out form. Please open it to review the data."
this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody})

With the plethora of PDF viewers out there that implement only some of the Acrobat JavaScript API - some more, some less - I recommend testing for the existence of any functions that your document requires before trying to use them. Wrap your code in the snippet below to let the user know that they are using a less capable viewer than what you've programmed the document for.
if (typeof this.mailDoc == 'function') {
// The viewer can mail documents
}
else {
// Warn the user somehow
}

Related

Open a CEP dialog from a CEP extension in After Effects

I have a CEP extension in After Effects and I want it so that when a user clicks a button, a settings dialog opens up in a new floating dialog box. Seems like it would be such basic functionality but somehow I'm not seeing anywhere in the (admittedly sparse) documentation how to open up a dialog box. I've seen some other people say that you can make a hidden extension which opens the dialog, but I've seen no example of that and it is unclear how that would work to me.
You can look up documentation for ScriptUI. Heres a link to the pdf: https://adobeindd.com/view/publications/a0207571-ff5b-4bbf-a540-07079bd21d75/92ra/publication-web-resources/pdf/scriptui-2-16-j.pdf
You can create a dialog either in a function in the jsx, or give it its own jsx page and //#include it onclick.
I know this is kind of a generic answer, but incase anyone else is having trouble this will give you a good jumping off point.
So in order to provide the functionality you need, you'll have to initialize a dialog box first, then add a button, then force it to open a specific settings dialog. I recommend something like this:
var dialog = new Window("dialog");
dialog.text = "After Effects Dialog Script";
//Contents
var newMsg = dialog.add("group", undefined, {name: "newMsg"});
newMsg.orientation = "column";
var newMsgText = newMsg.add("statictext", [0, 0, 400, 40], "", {name: "newMsgText", multiline: true});
newMsgText.text = "Would you like to open a settings dialog?";
//Button UI
var buttonPanel = dialog.add("group", undefined, {name: "buttonPanel"});
buttonPanel.orientation = "row";
buttonPanel.alignChildren = ["center", "bottom"];
var enter = buttonPanel.add("button", undefined, undefined, {name: "ok"});
enter.text = "Continue";
enter.value = true;
var cancel = buttonPanel.add("button", undefined, undefined, {name: "cancel"});
cancel.text = "Cancel";
cancel.value = false;
//Runs the dialog code
dialog.show();
//Grabs answer to yes or no question
var dialogInput = dialog.show();
if(dialogInput == true){
app.openDlg (prompt, filter, multiSelect); //Essentially
}
else {
alert("The action was canceled.");
}
You will have to find the direct path to the CEP dialog you wish to open. I'm unfamiliar with them and their integrations to After Effects, so I can't help you much beyond getting the script set up. However I have a few comments on resources that may be of assistance here too.
That ScriptUI resource by Peter Kahrel is fantastic. I've been working with it for the last few weeks. I wanted to add on to what Jake L said by dropping in a few more great examples of Extendscript Support because you kinda have to dig for the documentation, but it's definitely there.
https://extendscript.docsforadobe.dev/
I just stumbled upon the Extendscript Library recently, but it details a lot of functions, dives deep into events and event handlers, and even explains how you can set up an environment for extendscript via vscode.
I also like to check out NTProductions on youtube for assistance. I'm working in Indesign, but a lot of the extendscript functions work between the various adobe programs and you can even troubleshoot basic functions in the Adobe ExtendScript Toolkit.
And if you already have an Adobe CC account, don't forget to download the Scripting SDK from adobe APIs and Services. You'll have to sign in to get there, but it's a pretty useful local documentation.
https://developer.adobe.com/console/servicesandapis/id#
EDIT (again): I also found these after posting and will commit to adding more as I find them. Extendscript documentation must become more available! :-)
https://docsforadobe.dev/
http://yearbook.github.io/esdocs/#/

Node Webkit- opening and sending emails via outlook

I have a cordova app that I want to run on desktops using Node Webkit.
I need to replace cordova.plugins.email() function with a Node Webkit equivelant but am struggling to find the info I need.
Can anyone help?
//email composer
$('#stage').on('click', '#email', function(event){
var pdfatt = (this.getAttribute('data-pdfemail'));
var profforename = window.localStorage.getItem('profForename');
var profsurname = window.localStorage.getItem('profSurname');
var profemail = window.localStorage.getItem('profEmail');
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
body:'<p><img src="wp-content/uploads/2016/06/Email_Header.jpg"/></p><br><br>From:<p>'+profforename+' '+profsurname+'</p><p>Tel:'+proftel+'</p><p>Mob: '+profmob+'</p><p>Email: '+profemail+'</p><br><br><img height="30px" src='+baseurl+'"/wp-content/uploads/2016/06/download-pdf.jpg"/><br>Click To Download the PDF<br><br><br><p><img src="/wp-content/uploads/2016/06/Email_Footer.jpg"/></p>',
subject: 'subject',
isHtml: true
});
//alert('Service is not available') unless isAvailable;
}
);
});
The above code basically opens up a new email and pre-populates the email. I cannot find much information out there on how to do this. I have come across nodemailer but I don't think this is what I need as I would want to open up and email in Outlook and prepopulate, leaving the user to add the email address.
Many thanks
oh this is so simple, not sure why I tried to overcomplicate it! Turned out I sneeded to use the Nodewebkit GUI Library.
// Load native Nodewebkit UI library.
var gui = require('nw.gui');
gui.Shell.openExternal('mailto:test#example.com?subject=test&body=hello');

How to create ActiveX object in asp.net

How can i create ActiveX Object in java script using asp.net.what i need requirements to create that ActiveX object if i use any DLL to create that object and how can i create can anyone provide description of to create ActiveX object
My Tried code is:
<script lang="javascript" type="text/javascript">
function getSize()
{
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.getElementById('b').value;
var e = oas.getFile(d);
var f = e.size;
return(f);
}
function checkFileType()
{
var path = document.getElementById('file1').value;
var Index = path.lastIndexOf(".");
var length = path.length;
var filetype = path.substring(Index,length)
if ((filetype == ".doc") ||(filetype == ".pdf") ||(filetype == ".jpg") ||(filetype == ".gif") ||(filetype == ".xls")||(filetype==".odt"))
{
var x = getSize(); if (x > 5242880)
{
alert('only upto 5 MB file is allowed');
return false;
}
}
else
{
alert('Only .doc, .pdf, .jpg, .gif, .xls is allowed');return false;
}
}
</script>
<form id="form1" runat="server">
<input type="file" name="b" id="file1" onchange="return checkFileType();" />
<div>
</div>
</form>
In the above code i am getting this line in code
" var oas = new ActiveXObject("Scripting.FileSystemObject");" getting Exception is "0x800a01ad - JavaScript runtime error: Automation server can't create object".
Can anyone tell me to how can i create ActiveX object properly and what i need setting and which DLL's i use and all can anyone help me out.
Thank You
This validation is not a supported method in all the browsers.
Anyway, for IE9 or below (where .files is not supported) you can use this. To use this method, you will need to enable activex object in IE.
Go to Internet Options->Security Tab. Select trusted website, and click Sites button. It will give you an option to add the url. Add the url of your site, and save. Then click on the button saying "custom levels". It will open a list of options. Find the one saying "Initialize and script activex controls not marked as safe" and enable it.
Save and close the dialog boxes, and refresh your webpage.
Edit:
Few notes:
This is extremely unsecure method, so I would suggest improving compatibility and saying no to anything below IE9.
Secondly, this is something you have to enable on every single user's machine. Otherwise, that line will always throw an exception.
So, if you have to stick to IE8 or lower, and have control over your userbase, then only use this. Otherwise, just use flash upload method for IE browsers. Your users might hate installing flash, but there is nothing you can do.
P.S. I was doing this same thing about an hour ago. Lucky for you, I did all the research. :)
Edit: On a secondary note, can someone help me figure out how to get rid of XML dataislands without major rewrite? That is the only thing stopping me from saying goodbye to IE6.

Open Sharepoint folder with windows explorer from CRM 2011

I've been struggling with this issue for a while now,
and hope maybe someone in the community can provide a resolution.
I have a requirement which is to put a button on the a CRM account form which will have the same logic as the Open With Explorer button in a Sharepoint document library. The logic is required as the users have to do several click in order to get to this button, and open the required account's folder in windows explorer, which are:
Click Documents in navigation of the form, to open SP integration
Click documents in the SP view
Click library
Click the Open With Explorer button
The CRM is integrated with Sharepoint, and when the folder is opened in windows explorer it has the following sample link
http://{sharepoint}/CRM/7F9F72A1-4591-E011-AC6C-00155D773703/Documents/
Where the GUID 7F9F72A1-4591-E011-AC6C-00155D773703, is the account id in CRM.
From my research i have found that the javascript function that achieves this is
NavigateHttpFolder from the sp.js in Sharepoint.
From this function, and this link About Web Folder Behaviors
I've completed the following function.
var httpFolderDiv = document.createElement("SPAN");
function NavigateToFolder() {
document.body.appendChild(httpFolderDiv);
httpFolderDiv.onreadystatechange = NavigateToFolder;
httpFolderDiv.id = "navDiv";
httpFolderDiv.addBehavior("#default#httpFolder");
if (httpFolderDiv.readyState == "complete") {
httpFolderDiv.onreadystatechange = null;
var link = "";
var account = "";
var accountid = "";
var id = Xrm.Page.data.entity.getId().replace("{", "").replace("}", "");
link = "http://{sharepoint}/CRM/" + id + "/Documents/";
try {
httpFolderDiv.navigateFrame(link, "_blank");
} catch (c) {
alert(c.toString());
}
}
}
This function opens up the folder from Sharepoint in windows explorer, but with limitation if only that folder was previously opened directly from Sharepoint.
I believe that the logic I am missing in the code, is that I don't do mapping of the folder, the way sharepoint does.
I am aware that this folder can be mapped manually as a network drive, Connecting WebDAV Server Using Web folders, but this will not do the trick for me as this will have to be done on every client.
How can I achieve this by grabbing the complete logic from SP, or maybe running a console command from javascript to map the folder prior to opening it with the above function.
I know it's been a while, since this has been posted, but I stumbled upon it while searching for the exact same problem.
Here's what worked for me in SharePoint 2013:
<a href='#' onClick="javascript:CoreInvoke('NavigateHttpFolder', '[path to site]/[library name]/', '_blank');">
Click to open in Explorer
</a>
It's essentially the same function used by SharePoints own functionality.

javascript mailto attachment not showing up

i'm trying to create a small web app wherein in one form, the user may type in certain parameters as part of the message, then after he hits a button, it will show an Outlook (depends on his default email client) email client popup with all the details he placed.. and then it will include an attachment.
the javascript code looks like this:
function submitReport()
{
var remarks = document.getElementById('remarks').value;
if(remarks != '')
body += 'Remarks: '+remarks;
var href = 'mailto:bug_support#emailadd.com?subject=[Bug Report] '+menu_path+'&body='+body;
href += '&attachment="C:\\debug.log"';
var form = DomUtils.createForm();
form.setAttribute('action', href);
form.submit();
}
i tried alerting the "href" variable and it shows:
mailto:bug_support#emailadd.com?subject=[Bug Report]&body=message_bodyReport Type: MonthlyStart Date: 2010-05-01 00:00:00End Date: 2010-05-31 23:59:59&attachment="C:\debug.log"
and surely an outclient popsup with all the subject, recepient email address, body..
but no attachment. anybody encountered this before? :(
the outlook used here is 2007..
if i run the web app in IE, it actually says an error
"The command line argument is not valid. Verify the switch you are using."
any ideas?
There is no way for a web page to cause a browser to open the user's email client with a file pre-attached from the hard disk.
Use a form and process it server side, or provide simple instructions along the lines of:
<p>Send an email to foo#example.com
and attach your log file.</p>

Categories

Resources