I am trying to implement a function where users will be able to open appointments/meetings on performing some action. I found it can be done using ical.
var icsMSG = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Our Company//NONSGML v1.0//EN\nBEGIN:VEVENT\nUID:me#google.com\nDTSTAMP:20120315T170000Z\nATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:me#gmail.com\nORGANIZER;CN=Me:MAILTO::me#gmail.com\nDTSTART:" + msgData1 +"\nDTEND:" + msgData2 +"\nLOCATION:" + msgData3 + "\nSUMMARY:Our Meeting Office\nEND:VEVENT\nEND:VCALENDAR";
window.open( "data:text/calendar;charset=utf8," + escape(icsMSG));
But it is first downloading the ics file, and then only when a user clicks on the downloaded file, it will open the appointment. Instead of that, I want the appointment to be opened directly without downloading. Please help me with this.
Related
I currently have a javaScript in a pdf that adds the current date once the document is opened in adobe.
function dateToday()
{
var date = new Date();
field = this.getField("todayDate");
field.value = date;
}
dateToday();
Now I want to upload this documents on a Sharepoint. But logically when I open the docs in the browser the javaScript is not triggered and the date is not updated (also when printing).
Is there any way I can change the script so it triggers when the pdf is opened in a browser?
Or how can I change the script so that it instead prints an error message when downloaded and opened in Adobe?
Thanks!!
We use Muhimbi PDF Converter for SharePoint On-Open functionality to add Dynamic Content(Current Date, User name, etc). You can find more details at https://blog.muhimbi.com/2011/04/applying-user-specific-watermarks-when.html
They also provide various watermarking facilities for details see http://support.muhimbi.com/entries/23730002-What-are-the-watermarking-facilities-of-the-PDF-Converter-for-SharePoint-
I am trying to download a file to client side using following javascript code:
window.location = InsightRoute + "GetOrderXML?orderNumber=" + txtOrderNoVal
If the file is available then it will get downloaded to the client machine. But the issues is if no file is available for downloading, it
will simply gets redirect to a blank page
http://mysite/GetOrderXML?orderNumber=1
You should check whether the file is available for downloading before redirecting, for example like this:
if (sdpInsightRoute && txtOrderNoVal)
window.location = sdpInsightRoute + "GetOrderXML?orderNumber=" + txtOrderNoVal
This way, if the variable txtOrderNoVal is undefined, the redirection wouldn't take place.
If file is not available then use following code inside controller, so that the alert will pop up:
Response.Write("<script>alert('Item does not exist on this environment.');window.history.go(-1);</script>");
return null;
Use of: window.history.go(-1); If there is no file and since it is getting redirected to a new page: http://mysite/Insight/GetOrderXML?orderNumber=1, which can be avoided.
I am working on developing Outlook appointment. I have a requirement where
I have to create a file and download it . When I open that file it has to open in outlook and create meeting request pop up without using active x . Is there any api developed by Microsoft. Its better if the snippet is from java script
Right now I am able to open pop up with Meeting request in Outlook from the web browser. I am able to do this by enabling Active x controls But it works in IE only. Moreover active x will not be supported by Microsoft in near future.
Current code
var outlookAppObj = new ActiveXObject("Outlook.Application");
var objNS = outlookAppObj.GetNameSpace("MAPI");
var theMailItemObj
=outlookAppObj.CreateItem(0);
theMailItemObj.display();
Your code above creates and displays a regular message. You can achieve the same result using a mailto: link.
For an appointment, create an ICS file and the user download it - Outlook will be happy to open it. the user can then click Save.
Prepare ics file as var finalAttachedData = "ATTACH;FMTTYE= application/vnd.openxmlformats-officedocument.wordprocessingml.document;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=test.docx:"+base+"\n";
var icsMSG = ["BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Our Company//NONSGML v1.0//EN\nBEGIN:VEVENT\n" + finalAttachedData + "\nUID:me#google.com\nDTSTAMP:20120315T170000Z\nATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:me#gmail.com\nORGANIZER;CN=Me:MAILTO::testmail\nDTSTART:" + Date.now() +"\nDTEND:" + Date.now() +"\nLOCATION:" + "hyd" + "\nSUMMARY:Our Meeting Office\nEND:VEVENT\nEND:VCALENDAR"];
Basically I'm trying to trigger the download of a file which is constructed dynamically. In order to construct the file I need to pass a lot of information to the servlet.
This means I can't use GET, I should use POST instead.
In order for the download not to mess the application up, though, I must open a new window. The problem is that I cannot do this:
window.open(http://very.long.url.com/.../, "_blank");
since this would cause the URL limit to be exceeded and GET to be used instead of POST.
All information that needs to be sent to the servlet are in an object called "config.
My solution was to write a form in the new window with POST method, then add hidden inputs to it and then trigger the submit, like this:
var win = window.open("about:blank", "_blank");
win.document.write("<form method='post' id=donwload action='serveletURL'></form>");
$.each(config, function (name, value) {
var fragment = document.createDocumentFragment(),
temp = document.createElement('div');
temp.innerHTML = '<input type=\'hidden\' name=\'' + name + '\' value=\'' + value + '\'></input>';
while (temp.firstChild) {
fragment.appendChild(temp.firstChild);
}
win.document.getElementById("download").appendChild(fragment);
});
win.document.getElementById('download').submit();
And it works in Google Chrome and Firefox, but it doesn't work on IE. On IE (even IE 10), a download dialog with a "serveletURL" file name opens and nothing gets downloaded when I ask the file to be saved or opened.
I'm sure I'm missing something... How do I accomplish this??
Thank you!
Eduardo
I got a PDF embedded in my page, and I'd like to set something like a Javascript-callback to be called whenever the user clicks a link within the PDF.
Is there a way to accomplish this?
If you check out the Acrobat JS Reference for the minimum version you want to support, you'll see documentation on the HostContainer object.
In the PDF:
this.hostContainer.messageHandler =
{
onMessage: function(messageArray)
{
for(var i = 0; i < messageArray.length; i++)
console.println("Message " + i + ": " + messageArray[i]);
},
onError: function(error, messageArray){ },
onDisclose: function() {return true;}
};
In your HTML, assuming your PDF is inside an <object id="thePdf"> tag:
function messageFunc(messageArray) {
for(var i = 0; i < messageArray.length; i++)
alert("Message " + i + ": " + messageArray[i]);
}
document.getElementById("thePdf").messageHandler = { onMessage: messageFunc };
In your PDF, you'd also need to modify the links so they have a JS action that would post a message to the containing web page. This could be done programmatically (varying wildly depending on the language/library you use), or manually in Acrobat Pro.
this.hostContainer.postMessage(["urlClicked", "http://blah.blah.blah..."]);
Not terribly hard, but no one's ever heard of it. I'd be stunned if this worked anywhere outside an Adobe viewer (Reader/Acrobat) for the next several years.
If you want to send a message from your HTML to the PDF for some reason, it goes something like this:
var thePDF = document.getElementById("thePdf");
thePDF.postMessage(["This", "is", "an", "array", "too."]);
You could even yank out all the existing links and have the PDF request the links be opened by the wrapping HTML page... that way you can give the new windows names, close them from JS, etc. You can get down right snazzy.
But you have to be able to change the PDFs.
Your link is probably represented as a "Link annotation" inside your PDF file. Annotations in PDF can contain "Additional Actions", you could use a pdf processing software like iText (free for non commercial use) or Amyuni PDF Creator(commercial, usual disclaimer applis) to add a Javascript action to the "Additional Actions" collection of your link(s). You can invoke a page or method in your server using this Javascript code.
Client side:
PDF
$("#pdf-link").click(function(){
$.post('yoursite.com/phpfunctionpage/notifyPdf',
{event:'pdf'},
function(response){
alert(response['message']);
}, 'json'
);
});
Your server side:
function notifyPdf(){
$event = $_POST['event'];
if ($event == 'pdf'){
// handle notification here
echo json_encode(array('result'=>1, 'message'=>'notifiation successful'));
}
}
<a href="file.pdf" onclick:'javascriptFunction();'>Open the pdf file</a>
<script>
function javascriptFunction(){
}
</script>