Nokia N97 SDK Example Applications Guide |
Antiword Example
1. About this Example
2. Prerequisites
3. Design and Implementation
4. Usage details
5. Porting Log
Antiword is a console-based apllication ported on the Openc, It serves the following purposes,
ANTIWORD can be used for the following purposes:
- converting a MS-word document (i.e. .doc) file in to a plain text(i.e. .txt) file.
- converting a MS-word document (i.e. .doc) file in to a Adobe acrobat(i.e. .pdf) file.
- converting a MS-word document (i.e. .doc) file in to a post-script (i.e. .ps) file.
- converting a MS-word document (i.e. .doc) file in to a xml (i.e. .xml) file
To build the Antiword example application, go to the Antiword\group directory and build the application.
The definition for the whole application can be found in the bld.inf file in the group subdirectory of the applications main
directory.
This example requires a familiarity with the C programming language, and access to the Open C stanadard library documentation.
As, this example uses Open C Standard library, the reader is recommended to read the following topics from the SDK documentation
before proceeding:
- standard library how to
- descriptions on SYMBIAN descriptors is optional.
The program capabilities are defined in:
antiword.mmp file (EXE - executable): CAPABILITY NONE
- This application uses main() as an entry point for the application.
- The application is simple console based application.
- Antiword is C Application that is ported on the OpenC, following changes are made to the application in order to work on openc.
- All changes made to the Opensource code is under SYMBIAN macro.
- Some of the environment variables are set explicitly using openC's setenv() API.
- There is a subroutine fillArg() which converts the given input command string to Linux's argv() format. This enables the Application
to works similiar to that console-based application without having much changes to the commandline processing.
- Output of the conversion will be dumped on to destination file [i.e last command line argument ]{ where as the original application
expects the users to use the redirection operators for dumping the output to a target file }.
- some of the status messages will be prompted to the user in case of wrong input commands.
- The command-line help will be printed on the stdout. [ Original help text is used for this purpose ].
- The input data files ( i.e. font-related and mapping files for conversion ) are added as the part of /data/resources and this
directory and files in it will be exported to Antiword application's private folder, so that /private/A0001323/resources/
will be used as ANTIWORD_HOME directory in the application. The code has been changed to read the data files from the above
mentioned directory.
- It has its own icon and can be launched from the UI both in the emulator and in the device.
- Antiword is not able to convert the embedded image or any other embedded multimedia objects from the document file. It converts
only the text, in case if there is an embedded object.
- Some of the related files, which supports the embedded images is commented on the mmp file as this files has depends on the
Opensource's sprite library.
- -f formatted text output
- -t text output (default)
- -a <paper size name> Adobe PDF output
- -p <paper size name> PostScript output paper size like: a4, letter or legal
- -x <dtd> XML output like: db (DocBook)
- -m <mapping> character mapping file
- -w <width> in characters of text output
- -i <level> image level (PostScript only)
- -L use landscape mode (PostScript only)
- -r Show removed text
- -s Show hidden (by Word) text
- Converting .doc to .txt file
antiword <src_path>.doc <dst_path>.txt
- Converting .doc to .txt file using character mapping file.
Antiword takes 8859-1.txt as the default character mapping file, user can override this by providing any of the mapping file
(mapping files are present in antiword\data\resources\) as shown below,
antiword -m 8859-14.txt <src_path>.doc <dst_path>.txt
- Converting .doc to .pdf file
While converting .doc to .pdf, user has to provide the paper size as the argument. Availabale papersizes are: a4, letter or
legal
antiword -a a4 <src_path>.doc <dst_path>.pdf
- Converting .doc to .ps file
While converting .doc to .ps, user has to provide the paper size as the argument. Availabale papersizes are: a4, letter or
legal
antiword -a a4 <src_path>.doc <dst_path>.ps
- Converting .doc to .xml file
While converting .doc to .xml, user has to provide the dtd as argument to antiword. Availabale papersizes are: db (DocBook).
antiword -x db <src_path>.doc <dst_path>.xml
- Converting .doc to .txt file in Landscape mode
Antiword takes 8859-1.txt as the default character mapping file, user can override this by providing any of the mapping file(
mapping files are present in antiword\data\resources\ )as shown below,
antiword -L <src_path>.doc <dst_path>.txt
- Users are able to specify the width of the destination document using -w option as below,
antiword -w 30 <src_path>.doc <dst_path>.txt
- Users are able to generate the formatted text output using -f options,
antiword -f <src_path>.doc <dst_path>.txt
Note: Antiword takes the absolute paths for the input file and output file. the <src_path> and <dest_path> in the above example
refers to the absolute path of the source and destination path respectively.
A sample word file sample.doc is kept in antiword/data directory and the same file is exported to the \epoc32\winscw\c directory,
so that user can test the application with the following command strings.
- antiword c:/sample.doc c:/sample.txt
- antiword -w 20 c:/sample.doc c:/sample_w20.txt
- antiword -f c:/sample.doc c:/sample_f.txt
- antiword -a a4 c:/sample.doc c:/sample.pdf
- antiword -p a4 c:/sample.doc c:/sample.ps
- antiword -p a4 c:/sample.doc c:/sample.ps
- antiword -x db c:/sample.doc c:/sample.xml
The generated files from the above operations are kept in the antiword\data\results folder for further reference.
As this is an OSS based application, porting it on top of Open C involves following steps.
- antiword-0.37.tar.gz is extracted and makefile is analyzed for the dependency.
- All .c files are recognized and put it under antiword/src folder.
- All .h files are recognized and put it under antiword/inc folder.
- group folder is created and bld.inf and mmp file is created.
- All the .c files are specified under the SOURCE tag and ../src is given as the source path.
- ../inc is given as USERINCLUDE path. and the open C's standard include path is given as SYSTEMINCLUDE.
- the data files [ i.e some character mapping files and font files ] are recognized and put it under antiword/data and all of
this files are exported to a standard path [i.e /epoc32/winscw/c/antiword ] and the application is modified to consider this
path as ANTIWORD_HOME folder.
- As some of the files dependent on the Linux sprite library, these things are removed from the mmp file. [ these files are
kept in antiword/src just for reference, but these are commented in mmp file ].
- Application compiled easyly on top of OpenC after the above steps. It is just a day effort to make it compile on Open C.
Once the Application compiled, Application debugged on emulator and undergone several modifications to work on Open C. The
following steps describes those modifications,
- Some of the necessary environment variables are explicitly set using setenv() API.
- Path to the resouce files, font files and character mapping files are changed accordingly. The input data files ( i.e. font-related
and mapping files for conversion ) are added as the part of /data/resources and theses files will be exported to Antiword
application's private folder, so that /private/A0001323/resources/ will be used as ANTIWORD_HOME directory in the application.
The code has been changed to read the data files from the above mentioned directory.
- There is a subroutine fillArg() which converts the given input command string to Linux's argv() format. This enables the Application
to work similiar to that console-based application without having much changes to the commandline processing.
- Output of the conversion will be dumped on to destination file [ i.e last command line argument.], { where as the original
application expects the users to use the redirection operators for dumping the output to a target file }.
- All changes made to the application is under SYMBIAN flag. User can track these changes easyly.
After the above changes, application start working on the emulator and with few changes [ like increasing the stack and heap
size of the application ], Antiword starts generating pdfs, postscripts files successfully on the device.
|
© Nokia 2009
|

|