Creating an MS Word document in an Android App - android

I am working on a client project for an android app and wanted to confirm if the designed solution appears to be utilizing the most appropriate technology and resources.
The application gathers data from the user via a series of questions, compiles the data into a single human-readable document, then sends the document out via email. My client requires the delivered doc to be in MS Word format. I am currently building my doc in the app using xml, setting the extension type as ".doc", then sending. Since the latest versions of MS Word seem to have no problem handling these types of files, this seems to be the most appropriate solution.
Is there anything obvious that I am missing? Should I be handling this another way?

You aren't writing DOC files correctly. If really need to save .DOC files I suggest you read this .pdf regarding thd DOC file format put out by the OpenOffice team.
As you are already writing the file in XML consider using Microsoft's Office XML format instead of writing the XML to a .DOC file.

Related

Android Bot Application using AIML

I am developing an Android Bot application which will take input from the user, check for a matching string in the AIML file and give corresponding output.
I know Android programming and also I have AIML files ready. The only problem I am facing is to fetch the output from the AIML files.
I have gone through some answers but I could not figure out a solution. I would be happy if you could explain it in detail.
I am using Android Studio for the development.
I used this tutorial to help me get started with my basic application that accepts my input, scans for the AIML files, and gives corresponding response.
The only issue with this tutorial is that it will just accept your input, scan the AIML file and search for matching text in the <pattern> tag and respond with whatever is present in the corresponding <template> tag.
If you have <oob> tags in your AIML files which perform special tasks like opening applications, searching on internet etc., you will have to write your own code which will do following tasks:
Scan the bot's response for presence of <oob> tag.
Remove the <oob> tag and contents between <oob> and <\oob> tags.
Perform whatever task is mentioned in those tags.

How to create an MS Word document within an Android app

I want to create a word document within an android app and send that document through mail.
Is there any tutorial for creating a word document in android. I have gone through several other questions on this website but i didn't got a clear answer.
can we do this on Android using Apache POI.
If any any sample example exist then please mention.
Thanks in advance.
You can use any Java library in Android, so I do think this would be the way you could accomplish what you want (using Apache POI).
You can send the attachment by adding it as an extra to the Intent you use to create a mail message (lots of examples of that).
Apache POI looks your best bet, but note that the component that deals with Word docs only supports simple files:
HWPF and XWPF for Word Documents
HWPF is our port of the Microsoft Word 97 (-2003) file format to pure Java. It supports read, and limited write capabilities. It also provides simple text extraction support for the older Word 6 and Word 95 formats. Please see the HWPF project page for more information. This component remains in early stages of development. It can already read and write simple files.
We are also working on the XWPF for the WordprocessingML (2007+) format from the OOXML specification. This provides read and write support for simpler files, along with text extraction capabilities.
You should seriously consider whether you can use a different format for your emails - plain text, or maybe HTML.

creating an emailable or printable document using an Android app

Can anyone recommend a good source (either a tutorial or book?) on how to generate a .doc file from an Android App?
I am completely new to programming and don/t understand most of what I read as answers here, hence the need for a recommendation: I need to learn!
What I'm after is to be able to produce a document based on a standard template, containing a choice of standard paragraphs with user insertions, which can then be emailed, all from a smart phone or tablet.
Unfortunately I think you have a research task on your hands. If your requirements allow you to create an Open Office XML document then its possible to insert the user's paragraphs 'by hand'.
An Open Office XML document is just a zip archive with XML files inside of it. Unzip the template document using java.util.zip and locate the word/document.xml file inside. Insert the user's text using the DOM and persist the file.
Another approach would be to try to get docx4j integrated into your Android project. My guess is that this project reference many libraries that are not included with the Android SDK.
Good luck and hope this helps.

BIRT, Android and reports

We have an IBM Maximo system that has BIRT reports built in. We are also in the process of writing an Andriod app that needs to be able to run a report (on the server) and get the PDF version back into the app (or at bare minimum, the HTML version of the report). Is there any built-in functionality for this with BIRT or Maximo??
My team have something similar, but we scrapped the idea of using the .rptdesign files stored on the maximo server, and solved it by setting up the BIRT runtime: (Download here).
If you have direct access to the DB you can setup the runtime with the report(s) you need and play around with the parameters.
Say that one have a report called "report1" stored on "localhost:8080" and the report contained 2 parameters called "StartDate" and "EndDate" this is how one would do it:
Instead of using the standard URL with the frameset servlet mapping: "localhost:8080/birt/frameset?__report=report1.rptdesign" and let the user run the report them self, change the servlet mapping to run.
To just run the report, without getting the parameter dialog to provide values for the two parameters, one just have to parse the parameters to the end of the URL - &StartDate=2011-01-01&EndDate=2011-01-02.
To download the file in PDF format append the viewer command option "__format=PDF" to the end of the URL.
So the end result will look like this:
localhost:8080/birt/run?_report=report1.rptdesign&StartDate=2011-01-01&EndDate=2011-01-02&_format=PDF
This will download the file in PDF format without any interactions to the actual BIRT runtime.
Hope this gives you some ideas anyways, I know it's not an optimal solution. But at least it's something.

Create PDF / Word (Doc) file within app

Is there a definitive method of creating either a PDF or a MS Word Doc file within the app and email it immediately (and possibly, also store it).
I have been trying for quite some time and have found out the JAVA libraries: apwlibrary and iText. But both of them dont provide any tutorials of sorts.
Could anyone point me in the right direction?
EDIT: Come to think of it, is could an online PDF generator be used, first by sending the data to the service, then retrieve the result and save it on the phone?
I would recommend apache fop http://xmlgraphics.apache.org/fop/
you can use standard FOP to generate pdf.
Unless it is a core feature of your device to create a pdf file I would suggest not to do it yourself. Adding PDF creation is going to be quite a lot of work potentially depending on your performance needs. Java libraries will be easier to add but less performant. Native libraries combined with Java will be more hazzle to maintain build and bug fixing wise.
If you just need to email some information why dont you create a message text in html and use a intent to email it with the build in email program instead? Or if you want you could e.g. put the PDF generation on a server and just email a link..
I'm working right now with JasperReports, an open source library to create reports in Java and export them to PDF, DOC, XLS... Using it in conjunction with iReport to create a group of templates makes it really easy to create files filled with content from different types of sources (I'm using JavaBeans).
If you don't like the idea of having static templates (That's a bit annoying depending on your needs), you can always take a look at DynamicJasper (The examples on the website are great).
Good Luck!
I have used Apache POI. It seemed to work well. http://poi.apache.org/
This actually, http://poi.apache.org/hwpf/

Categories

Resources