3 Sample Applications
Each of the sample applications included in this SDK is designed to highlight a specific aspect of the technology's functionality. We ship built versions of these sample applications. The compiled executables should be in the root directory where the product is installed.
The following copyright applies to all sample applications shipped with this product:
Copyright © Oracle 1993, 2014
All rights reserved.
You have a royalty-free right to use, modify, reproduce and distribute the Sample Applications (and/or any modified version) in any way you find useful, provided that you agree that Oracle has no warranty obligations or liability for any Sample Application files.
This chapter includes the followinig sections:
3.1 Building the Samples on a Windows System
Microsoft Visual Studio project files are provided for building each of the sample applications. For 32-bit versions of Windows, versions of the project files are provided for Visual Studio 6 (.dsp files) and Visual Studio 2005 (.vcproj files).
Because .vcproj files may not pick up the right compiler on their own, you need to make sure that you are building with the Win64 configuration in Visual Studio 2005. For 64-bit versions of Windows, only the Visual Studio 2005 versions are available.
The project files for the sample applications can be found in the samplecode\win subdirectory of the Oracle Outside In SDK.
For specific information about building the sample applications on your UNIX OS, see Chapter 5, "UNIX Implementation Details."
3.2 An Overview of the Sample Applications
Here's a quick tour of the sample applications provided with this product. Not all of the sample applications are provided for both the Windows and UNIX platforms. See the heading of each application's subsection for clarification.
This section includes the following sample applications:
3.2.1 demoserver_node.js
The sample application demoserver_node.js is a minimalist web server designed for testing the features of Outside In Web View Export. Its main use is to automate the conversion of input files via the Web View Export Sample Application wv_sample_exporter, and serve the results to a web browser.
Architecture
demoserver is implemented as a javascript file that is executed by node.js. Node.js is available on multiple platforms, and demoserver should work on Linux as well as Windows.
Installation
Installation requires the following steps:
-
Install node.js
-
Get demoserver.js and demoserver.config from the sample application directory demoserver_nodejs
-
Edit demoserver.config to configure demoserver. This part may be optional if you run the demoserver from the same directory where it appears in the Web View Export SDK. By default, it is configured to look for the Web View Export executable files in the demo subdirectory of the SDK.
Once configured, you run the server with the command line:
node demoserver.js
Configuration
At startup, demoserver.js will load demoserver.config and use the options as specified. These options are only read at startup time, so if you wish to change an option, you must restart demoserver.
Here is a sample configuration:
{ port: 80, // map of virtual directories dirmap: [ { vpath: '/samplefiles', fspath: '../../samplefiles' }, { vpath: '/out/', fspath: './output' }, { vpath: '/assets/', fspath: '../../assets'}, { vpath: '/scripts/', fspath: '../scripts'}, ], export_config: { // exporter program exporter: "../../demo/wv_sample_exporter.exe", // (optional) extra parameters for exporter program, as an array of strings params: ["-r", "/assets/", "-s", "/scripts/demoapp.js"], // Output virtual directory output: "/out/", }, }
Note that this file is a Javascript object declaration, and will be directly interpreted as such at run time. If you break the Javascript syntax of the file, the server will exit with an error message. (It's actually Javascript as opposed to JSON format. The syntax is mostly the same, but because Javascript allows comments and JSON does not, Javascript was used.)
Remember these rules:
-
No semicolons
-
Backslashes in strings must be escaped as \\
-
Either single or double quotes are allowed as string delimiters, but must be paired like-with-like
-
Don't change the { and } at the beginning and end of the file.
Configuration Parameters
-
port: [Optional, defaults to 8888] This is a number that specifies the port on which demoserver will be listening. If you use port 80, you can just point your browser to http://localhost (or http://127.0.0.1). Any other value will need to be specified in your browser's address bar; e.g., listening on port 666 would require http://localhost:666
-
dirmap: [Required] This defines the set of virtual directories for your web server. In Javascript syntax terms, this setting is an array of objects, each of which contains a field vdir, which defines a virtual directory, and fspath, which tells the server what real directory to use when files from this virtual directory are requested.
You may add any number of virtual directories, and a virtual subdirectory may be defined whose physical directory is not a subdirectory of the virtual parent's physical directory.
-
export_config: [Required for exporting] This is a collection of values that must be specified in order for the demoserver to be able to export files to HTML5. It consists of the following values:
-
output: [Required for exporting] This field's value must be a virtual directory defined in the dirmap. When exporting files, demoserver will tell the export program to put its output in this directory.
-
exporter: [Required for exporting] This is the path to the executable that will be used to export files. In theory this can be any command line application that accepts the input file as its first parameter and the output file name as its second parameter, but demoserver does assume that this program will be wv_sample_exporter, and generates additional command line parameters for this specific program.
-
params: [Optional, no default value] An array of strings. If you would like your exporter application to have any further parameters on its command line you can specify them here.
-
prefix: [Optional, no default value] This is a string which will be used as the prefix for your output file names. For example, if export_config.prefix is set to '_', then when exporting a file named file.doc, the primary output file that will be specified to the exporter is _file.doc.html
-
-
defaultMime: [Optional, defaults to 'application/octet-stream'] A string value that will be used as the default MIME type provided by the server for files whose file extension doesn't match a commonly used Web format.
filebrowse.html
This is a page supplied with demoserver_node.js that you can use to navigate directories on your file system to conveniently export documents at will.
3.2.2 wv_sample_exporter
The sample application wv_sample_exporter uses the Web View Export SDK to produce HTML5 output files. It has two required parameters, the first being the input file name and the second being the name of the primary output file; as in:
wv_sample_exporter InputFile OutputFile
The following command line switches are used with this application to modify the way the HTML5 output is produced.
Switch | Parameters | Function | SDK Function |
---|---|---|---|
-p | 'f', 'c', or 's', indicating structure that is flat, chunked (Ajax), or streaming (Ajax) | Chooses the structure of the output files generated during the export process. | maps to value of SCCOPT_OUTPUT_STRUCTURE option |
-r | ResourcePath | ResourcePath is the base URL for .js, .css, and .png assets. | maps to option SCCOPT_URLPATH_RESOURCES |
-o | OutputPath | OutputPath is the base URL for links to generated output files. | maps to option SCCOPT_URLPATH_OUTPUT |
-s | ScriptUrl | ScriptUrl is a the URL of a javascript file to be linked from the output files. | maps to option SCCOPT_POST_LIBRARY_SCRIPT |
-c | CssUrl | CssUrl is the URL of a CSS file to be linked from the output files. | maps to option SCCOPT_EXTERNAL_STYLESHEET |
-n | ArchiveNode | ArchiveNode indentifies a node from the input file, to be used as the exported document (applies only to archive files, e.g., .zip) | maps to a record ID parameter passed into DAOpenTreeRecord |
-a | AttachmentId | AttachmentId identifies an attachment from the input file, to be used as the exported document (applies only to email message files.) | maps to a subdoc id value to be used in a call to DAOpenSubdocumentById with the id type of DASUBDOCID_ATTACHMENTINDEX |
-k | Key, Value | Key and Value are a key/value pair to be made available to scripts | maps to EXAddKeyValue |
-f | FontDirectory | FontDirectory indicates where the exporter should find fonts to use. | maps to option SCCOPT_FONTDIRECTORY |
3.2.3 demoserver_go
This is a sample server application very similar to the demoserver for node.js. It is written in the Go programming language; compiled executables are included as well as source code. Please see the readme.txt file in this application's directory for more information.
3.2.4 exsimple
This simple command line driven program allows the user to run a single source file through the software. The user can choose the source file, an output file and set the various options.
To run the program, type:
exsimple in_file out_file config_file
-
in_file is the input file to be converted
-
out_file is the output location
-
config_file is the configuration file that sets the conversion options. If no configuration file is specified, default.cfg in the current directory is used.
The configuration file is a text file used to set the conversion options. We recommend reading through the configuration file for more information about valid options and their values (use of invalid options results in exsimple not producing output).
Follow these instructions to set configurable options.
-
Set the Output ID to FI_HTML5 before running the software.
-
It is also recommended that you set SCCOPT_FALLBACKFORMAT to FI_NONE. This prevents the export of unidentified binary files as though they were text, which could generate pages of garbage output.
-
It is required that the "fontdirectory" section of the configuration file be set to point to a valid font directory.