Skip to content

surebert/docker-rtf-to-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTF To HTML Converter

This image is an http service used to convert rtf to html using libre office

Deployment using copy of project from docker site

docker pull paulvisco/http-rtf-to-html-converter

docker run -d \
    --name rtf-to-html \
    --restart=always \
    -p 127.0.0.1:9022:9022 \
    -e "port=9022" \
    paulvisco/http-rtf-to-html-converter

Build and Deploy

If you wanted to build and test this yourself

docker build --rm -t yournamespace/rtf-to-html .

docker run -d \
    --name rtf-to-html \
    --restart=always \
    -p 127.0.0.1:9022:9022 \
    -e "port=9022" \
    yournamespace/rtf-to-html

Connecting to the container from the host

docker exec -it rtf-to-html /bin/bash -c "export TERM=xterm; exec bash"

Checking Logs from the host

docker logs -f rtf-to-html

Installing additional commands to debug with yum

If you wanted to install nano or telnet from there for debugging

yum install telnet
yum install nano

Using The RTF to HTML Service

To convert RTF to HTML you simply pass mutlipart encoded form data to the service.

Example call from CURL in Bash

This assumes that the docker image was deployed to localhost on port 9021 and that you are in the test directory of this project where there are two files: one named watermark.pdf and another named my.pdf.

curl -F "rtf=@sample.rtf" http://localhost:9022/convert > sample.html

Example call from CURL in PHP

You could use any language that supports http request. This assumes that the docker image was deployed to localhost on port 9022 and that you are in the test directory of this project where there are two files: one named logo.png and another named styles.css. You can simply run the example.php file in the test directory of this project or use the code below.

<?php
  $ch = curl_init("http://localhost:9022/convert");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, [
      'rtf' =>  new \CurlFile(__DIR__.'/sample.rtf','text/rtf','sample.rtf')
  ]);
  $result = curl_exec($ch);
  file_put_contents("output.html", $result);

About

uses libreoffice, nodejs and centos to provide http based rtf to html converter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors