How to launch Word documents as templates from a browser? - java

I work for a non-profit who uses MS Access 2003 to keep track of donations and benefactors. Someone, a long time ago, wrote a huge VBA application inside access to keep track of everything, but we've outgrown Access's limitations. We're looking at replacing it with a web application (Java/MySQL), perhaps created with Wavemaker, but one feature which is very useful is the ability to launch a Word document (I don't know the name of the feature exactly), based on a template, that populates the template with some data from the Access DB. For example, a "Thank You" letter for a benefactor which is populated with their name and address.
I have no idea how to mimic this feature in a web application, and I'm open to any suggestions (even the abhored ActiveX controls). Any ideas?
Thanks in advance!

The general approach is not to automate client side. So you generate a PDF or word or perhaps even a rich text file server side then THEN provide a URL/link for the user to click on.
The user can then click on that URL (file) and the local client side software (either browser or word) can then open + render that file.
So a browser is quite happy to allows one to open a PDF or word (rtf) file FROM server side in the client side. And this includes opening such files with Word.
Attempting to launch CLIENT side software from a browser is not only a “high” risk adventure but if you setup such computers to allow the browser to create + launch + run + use such files client side then you open a security hole the size of a barn door.
What is to say with such security holes being opened the next site will not open or scan or look for files like “banking” or personal finance? So you really do not want nor can you attempt to automate client side software from a web browser.
However creating a PDF or even using some kind of web based report writer, they often have a “web export” option that creates a PDF or even Word format file that can be opened local. For example SQL server reporting services has a great PDF and Word export feature.
In fact if you using Access web services (that is Access web publishing for 2010), then the Access web reports render these reports near “perfect” in word and in fact Web Access Reports render better in Word then do client based Access applications!
So for example, looking at an Access Web based Report, you see this option:
If you click on actions then you get this option in the web browser:
Now, when you click on that, you can choose PDF or Word and your LOCAL client opens + renders the report. Really nice is all graphics and formatting is preserved in the web report (unlike client reports that loose their graphics).
The above of course is using Access Web publishing which just so happens to use SQL server reporting services. The “key” suggesting here DESPITE the fact that you don’t have or may not have SQL reporting services is that the creating + rendering of the document occurs SERVER side, and THEN the client can simply “open” or consume the report as PDF or in this case as above shows Word. Once again this means no client side automaton is required.
So create the document or template 100% server side. Depending on the reporting system and Web development tools you adopt then such tools might have built in Word creating system. In above I ONLY used MS Access to create this web site and the Access Web development tools are based on SQL reporting services which has the PDF and Word export built in as per above shows.
If you don’t have a report system you can still adopt a PDF format system or even use a common format like Rich Text which CLIENT side MS Word handles and opens quite well.

Related

NPAPI alternative for live file editing

I currently have a web app, which allows users to download files to their computers, edit them with their own editors and automatically sends them back to server upon saving and sends some extra data when closing the file. It utilises a Java applet to handle the client side processing which includes
file download,
sending request to lock the file,
opening the file in default desktop app,
watching for changes,
file upload back to server,
sending request to unlock the file upon closing.
Since chrome will stop supporting NPAPI in September, I need to create an alternative while maintaining the funcionality. I wasn't able to find many alternatives. The only thing I found that would be able to achieve at least something is Native Messaging, but still I can't imagine how could I use it to emulate the behavior of the java applet.
So the question is - what are possible alternatives I can use to replace the applet?
Looking at your comments, I'm going to break down your question into 2 basic questions:
How does native messaging work?
How do I download a file and launch it in an application, etc, in a windows application?
Native messaging essentially allows you to launch an application (which must be registered when installed to allow it to work this way) which can communicate with your extension. You can then talk back and forth with your native messaging application from your extension (or from the web page proxying requests through your extension); your messages have to be essentially json formatted (on the javascript side you provide json encodable values and on the executable side you have to read that from stdin and parse it, then write to stdout the result; there are also 2 byte integers preceding each message indicating the length of the message).
basically once you have communications, you just have to make your application be able to respond to a message that tells it to download the file by doing so, etc. This is something you'll have to figure out how to do -- you could do it with a python script, a windows exe, a .net app, or whatever you want that can be executed, but each has advantages and disadvantages.
Hope that helps

Embedding Microsoft Word in a browser window (cross-browser)

Background
Our web application stores Microsoft Word documents which users want to edit (ideally with Word) in their browser of choice.
To access the web application (and the documents), users must login. As they are unwilling to login whenever they edit a document, document retrieval and storage must occur in their login session, which is easiest to accomplish if document download and upload is done by the browser.
Question
How can I embed Word into (or at least invoke it from) a browser window to edit a document the browser has retrieved from the server? It should work in both Internet Explorer and Firefox.
Own Research
ActiveX is not supported by Firefox.
There is not javascript api for invoking (let alone embed) native applications. Even if there were, I don't see how I could pass the document, and neither Internet Explorer 10 not Firefox 20 appears to offer an api to write a file to disk.
I could write a (signed) Java Applet to invoke Word, but ensuring that all changes are uploaded to the server appears difficult (what if the user closes the browser window before saving in Word?)
Eclipse has this nice feature of permitting in place editing word documents. This appears to be part of their SWT toolkit, but as that requires native code, I am not sure how to deploy it is an applet?
I don't know if they are embeddable for free, but you can take a look at Microsoft Office Webapps

PDF printing to client's printer without opening them

I am working on a web application developed in Java with struts running on Tomcat. I have a requirement in the web application as follows:
One JSP page having a list of PDF files each associated with a checkbox. The JSP page has one Button. Once the user selects the PDF documents he wants to print by selecting the associated checkboxes, user clicks on the button.
Then all the selected PDF docs should be sent to a specific local Printer( i.e. printer connected to the client machine where from user is accessing the web application). The selected PDF files should not be opened either in acrobat reader or in browser. The PDF docs should not be visible to the user while being sent to printer.
Could anyone please help me in implementing this requirement?
It is possible with Internet Explorer and ActiveX. Search about "auto print" and "silent printing" with Google. You may have to lower security settings in Internet Explorer for that.
We're using it here for some Intranets from our Customers.
For Firefox you may be able to trigger the print dialog via javascript. (http://stackoverflow.com/questions/975652/silent-print-a-embedded-pdf)
If this is the case you can disable print dialog in FF with setting print.always_print_silent=true in about:config.
Never did it on my own, so I cannot say for sure if it works like the ActiveX thing does.
For Chrome there is an issue requesting same feature like FF has. See https://code.google.com/p/chromium/issues/detail?id=31395.
You will most likely have to use a Java Applet for this. The browser have no inherent capability to print a pdf document. You may be able to access the "standard" adobe plugin, but to my knowledge it is not exposed to the standard scripting environment.
You can look here: Can a Java Applet use the printer?
Note: it is recommended to have the applet signed to prevent security restrictions and/or annoying questions to the user to allow access to printer.
You'll also need some form of PDF renderer in your applet (to render to printer). Something like http://java.net/projects/pdf-renderer/, read more here: http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/
That is not possible with JavaScript. It is possible with either Flash or a Java applet. In either case, you will need to be able to use both the Printer drivers and a custom PDF reading toolkit. There are adequate plugins for both for PDF reading, and both come with a printing API.
If I may say so, this is a bad requirement -- it is not good to force a user to print a document without reading it -- and should be re-negotiated, especially since it is trivially simple to have those documents print to PDF anyway.

How to program a browser integration with an external editor like MS Word in Java?

You may all have seen online content management systems or publishing platforms, where one can edit a page, but for convenience, the editing is not done in the browser, but instead in Microsoft Word. So whenever you open the page to edit it, the current page is send to MS Word and after completing the editing, Word sends back the page to the server.
A good example is Confluence. Instead of using the built-in WYSIWYG editor, you can also edit a page in MS Word.
How does this work technically? I want to program something similar on a Java servlet based web app. The first part is easy. I convert my page into the format of the external application and send it to the browser setting the correct mimetype. The external application will open the document. But I have no idea how the second part works. How does this application sends the file back?
Please send me any pointers you might have. My main problem is probably that I really don't know what I should search for. Also, if you know any opensource Java based projects doing something similar, I would like to study them to get started.
PS: Please feel free to change the title of this question!
One way this works is if you start Microsoft Word not wih a file as an argument, but witha n http/https URL that points to a WebDAV-supporting location. In this case Word will send the file bach witha PUT method when saving.

How to build a simple application which can capture user input and produce a printable output

We need to build the following application:-
User punches in couple of inputs into a form (e.g. customer name, insurance policy information, bank details and the insurance amount). The application is supposed to take a print copy with 3 perforations which contains the above information (one for the customer, insurance agent and the insurance firm)
The end users in this case (insurance agents) are not tech savvy and would like to have an application with the smallest footprint which can be launched from a CD. Also do note that they might not have an internet connection.
We are looking for ideas on frameworks we should use to build this application. Note: We are proficient in java only. Does this application need to be a web application or a simple html with some pdf generation capability. Looking for suggestions here?
If all you need is to enter the information and print the PDF, you can just create a PDF form with editable fields using OpenOffice, no need to code an application for that.
However if you need to save the data, you then can use PDFBox to parse the filled form and put its data into a database later.
Despite the 'web' part of Java Web Start, it might suffice to supply an applet (yes, I did mean applet not application) on the CD that is launched using JWS.
As of Java 1.6.0_10+, applets can be dragged from the web page (on the CD) where they reside. If a dragged applet is configured by JNLP (installed using JWS), it will then install itself into the user's system.
Further, JNLP offers a way for even sand-boxed apps. to use the printer. See my demo. of the JNLP PrintService for more details on that.

Categories

Resources