Convert PDF to EPS

You may want to convert a PDF file to EPS format, for example to insert it in a Microsoft Word of LibreOffice Writer document.

One way to do is like this. This workflow creates an intermediary Postscript file during the conversion. Note: no need to provide name of the output EPS file, it will be created automatically.


  • pdf2ps myfile.pdf; ps2eps

Find paragraph breaks in LibreOffice

To find paragraph breaks (i.e. the ASCII line feed character 0A hex)  in LibreOffice, use the currency symbol “$” as the search string.

Make sure to look into “Other options” and check “Regular expressions” in the “Find & Replace” dialog.


By the way, searching for “\n” and replacing it with “\n” can be done only once, as on the repeated action there will be no matches found anymore and searching for “$” must be done instead. Read some more about this bug/feature/inconsistency here.


LibreOffice add external data field to document

You may want to use some external variables that are shared between several of your Writer documents.

One way to do that would be to use Mail Merge, but that may not be what you prefer.

Another solution is to insert the data you want as DDE link to the source document.

Let’s say you have a string in your Calc spreadsheet and you want it to show up in your Writer document:

  • Open the Calc spreadsheet
  • Copy the cell
  • Open the Writer document
  • Select menu Edit -> Paste Special -> DDE Link
  • Press Ctrl+Z
  • Press Ctrl+F
  • Select Variable tab
  • Select Type: DDE Field
  • Select the name of variable in Select control
  • Click Insert button

The method is a bit clumsy, but it works just fine. Possibly you may stop after pasting the DDE link, which gives you a fragment of a table, depends upon what do you need.

To see field values instead of field codes:

  • Select menu View -> Field Names (or press Ctrl+F9)

Convert ODT to DOC

Just like when converting ODT to PDF, you can use LibreOffice ( in command line mode for high quality conversion of all of the ODT files in a directory to MS Word DOC files:

  • libreoffice --headless --convert-to doc ./*.odt


  1. Before you run this command, make sure that LibreOffice ( is not running in background. Otherwise it will fail.
  2. Use ./*.odt instead of simply *.odt, because otherwise the program will consider file names beginning with “-” to be an argument and will fail.

Unzipping, editing and zipping ODT documents in python

This is a python script created with a single purpose: to test unzipping of (LibreOffice) word processor .odt document file, searching in its contents for a certain text and replacing it with a substitute, and, eventually, zipping it all back together to form a new .odt document.

If you copy and past this text, remember, that HTML formatting may spoil the code, so please check it for any introduced mistakes. Especially since this is python with its indentation issues.


# Just a test script
# Demonstrates unzipping, editing and zipping of ODT documents in python
# Source ODT file "in.odt" shall exist in "/tmp"
# If ODT file contains string token, it will be replaced with string replacement

Read the rest of this entry »

Unzip and zip ODT files

As you probably know, ODT files of (LibreOffice) are in essence just ZIP archives.

It is very easy to unpack them. But it is not so easy to create them. If you simply zip the contents of unpacked ODT and change the extension to .odt, it will not work.

The key here is that the mimetype file shall come into the archive first.

Two simple bash scripts are given here to extract and then pack back the ODT files.


Script odt_extract (provide  .odt file name and desired destination directory as command line arguments):

echo "Extracting ODT file $1 to directory $2 ..."
unzip "$1" -d "$2"   #1>/dev/null


Script odt_compress (provide  source directory and desired .odt file name as command line arguments):

echo "Compressing contents of directory $1 into ODT compatible document $2 ... "
# Move into document source directory
cd "$1"
# Special zipping procedure to create correctly structured ODT file
# Remember that if the provided resulting file path is relative, it shall be so in respect to the current working directory!
# First comes the "mimetype" file ...
zip -0 -X "$2" mimetype   #1>/dev/null
# ... then everything else follows
zip -r "$2" * -x mimetype   #1>/dev/null

Using SQLite database with

To use SQLite database with or LibreOffice:

First install:
sudo apt-get install unixodbc unixodbc-bin
sudo apt-get install libsqliteodbc

Then run:
ODBCCreateDataSourceQ4 (create data source for “user”)
ODBCManageDataSourcesQ4 (if needed)

In Office:

First register the database in Base, then go on using it in Calc and Writer

Connect to an existing database -> ODBC

View -> Data sources

View -> Data sources



If for any reason the configuration fails, you can try to set it up manually.

First, edit file /etc/odbcinst.ini and enter database driver data, like this:

Description=SQLite3 ODBC Driver

Then enter database specific parameters in a hidden file .odbc.ini in your user directory (if the database is to be used by a single user), e.g.:

Description=My test database