Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Converter manual

Florian Dejonckheere edited this page Jun 21, 2017 · 1 revision

OpenWebslidesConverter manual

overview

  1. What it does
  2. Parameters
  3. converter.properties file
  4. Template
  5. Use as a command line tool
    1. Logging
    2. Command
  6. Use inside/with another java application
    1. As library
    2. Using reflection
  7. Technical details

What it does

The OpenWebslidesConverter is a tool to convert .pptx files into html. The converter does not rebuild the slides with each element on the same place or same size. It is the meaning to interpret the content and create generic code. The information stays the same but it is possible to use another template without changing any code.

You have two choices as output. The first is just raw, plain html code. Secondly, it is also possible to generate code for the shower and a template.

Parameters

There are a number of parameters.

  1. input file: must be of the type .pptx or .pdf
  2. output folder: where the converted file(s) should be placed
  3. output type: convert to plain code (raw) or with a template and shower (shower)

Values can be set on the command line or within the converter.properties file. If not, default values are used.

A short overview:

parameter command line value default
input file -i *.pptx | *.pdf required
output dir -o * output optional
output type -t raw | shower raw optional
zip as output -zip none optional

If the output type (-t) equals shower:

parameter command line
course -co optional
chapter -ch optional

The default values can be changed: converter.properties overwrites the default values, the command line arguments overwrite the properties values.

converter.properties file

One way to set the values is to create the converter.properties file in the same directory as the converter jar. An example:

#directory for the log file: must end with "\\"
LOG_FILE=c:\\temp\\log\\

#output type: raw or shower
OUTPUT_TYPE=shower

#directory for the converted files
OUTPUT_DIR=converted files

Template

When using shower as output type, a template is used. The template files are stocked in template.zip, which is saved in the package openwebslides inside the builded jar.

Use as a command line tool

Logging

There are 2 ways of logging: -cl (console log) and -fl (file log). Console logging shows a short message in case of an error while the log file also contains the stack trace. The default location for the log file is c:\temp\.

There are four possible ways to set the logging:

flag(s) logging
none console logging
-cl console logging
-fl file logging
-cl -fl console and file logging

Adjusting LOG_FILE=... in converter.properties is the only way to change the directory where the log files are created.

Command

$ java -jar OpenWebslidesConverter.jar -i <input file> [options]

Examples:

$ java -jar OpenWebslidesConverter.jar -i file.pptx -t shower -fl
$ java -jar OpenWebslidesConverter.jar -i file.pptx -o "converted files"
$ java -jar OpenWebslidesConverter.jar -i file.pptx -o out -fl -cl

Use inside/with another java application

The starting point of the tool is the OpenWebslidesConverter class. It has two entry points:

  • + static main(args : String[]) : void
  • + static queueEntry(args : String[], outputStream : OutputStream, queue : Queue<String>, id : long) : void

queueEntry is a method to get control over the logging inside another project. An empty Queue (java.util.Queue) will be filled in with logging lines. id is used as a unique identification in the logs in case multiple converters are running parallel. The result of the conversion is written as a zip file to the OutputStream. It can be a FileOutputStream, ByteArrayOutputStream ...

The String array args represent in both cases the command line arguments.

As library

Just include the .jar file as a dependency or library inside your project. Use one of the above static methods.

Using reflection

Another way is to load the converter dynamically at runtime using reflection. You can use following code as inspiration.

try {
    Queue<String> queue = new ConcurrentLinkedDeque<>();

    // Getting the jar URL which contains target class
    URL[] classLoaderUrls = ...

    // Create a new URLClassLoader
    URLClassLoader urlClassLoader = new URLClassLoader(classLoaderUrls);

    // Load the target class
    Class<?> OpenWebslidesConverter = urlClassLoader.loadClass("openwebslidesconverter.OpenWebslidesConverter");

    // Getting a method from the loaded class and invoke it
    Method method = OpenWebslidesConverter.getMethod("queueEntry", String[].class, OutputStream.class, Queue.class, long.class);
            
    final Object[] param = new Object[3];
    param[0] = args;
    param[1] = outputStream;
    param[2] = queue;
    param[3] = id;
 
    method.invoke(null, param);

    ... //read the queue or do other work
} catch (...) {
    ...
}

Technical details

video conversion

HTML5 only supports three types of video. Those are: MP4, WebM and Ogg. If the video in the PowerPoint file has another extension a placeholder is shown. The original file could still be inserted within the images folder.

Clone this wiki locally