GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
15 MIN READ TIME
ODF

Auto-generate ODF documents

Marco Fioretti demonstrates how you can create the same office files that you can make with LibreOffice – but without LibreOffice!

Part One!

Don’t miss next issue, subscribe on page 16!

Part One!

Don’t miss next issue, subscribe on page 16!

OUR EXPERT Marco Fioretti is a long-time open source trainer and writer, and an aspiring polymath.
Credit: https://groups.oasis-open.org

QUICK TIPS

Whatever format they are in, if you are going to process lots of files with shell scripts, give them names without spaces. It will make the scripts more robust, and easier to write or debug.

QUICK TIPS

Whatever format they are in, if you are going to process lots of files with shell scripts, give them names without spaces. It will make the scripts more robust, and easier to write or debug.

So-called office documents, the collective name given to complex text files with rich formatting, spreadsheets and presentations, are a necessary evil of modern life. Creating such files without any programming skill is easy with suites such as LibreOffice. However, using such tools to manually create large numbers of documents, spreadsheets or slideshows can be really time-consuming. Ditto for creating many versions of the same document, each with different values of one or more variables.

This two-part tutorial introduces a quick and dirty – but very flexible – general and important approach to solve this very problem, based on the OpenDocument Format (ODF) for office documents and really simple scripts. We say important for two reasons: first because, as you will see shortly, the data inserted in office documents with this method can be text (including whole files) and images of all sorts, generated on the fly or automatically extracted from all conceivable sources, from databases to email archives or scraped web pages. The second reason is its simplicity, which places it well within the reach of anybody with little time but a basic knowledge of scripting languages.

This first part of this tutorial explains what ODF is and why it’s made to order for the automatic creation of large quantities of similar documents, and demonstrates with a practical example how to create from the command line multiple text documents identical to those you could have produced with LibreOffice, Microsoft Office and similar programs. The second part will demonstrate how to extend the same approach to spreadsheets and presentations.

Internal ODF structure

To make a long, fascinating and very important story short (see the ODF history boxout, page 59, for more), ODF is the native format of LibreOffice and OpenOffice for texts, spreadsheets and slideshows, which Microsoft would have loved to destroy. You may think that a format suitable for such sophisticated programs would be very complex, and ODF files would be black boxes full of indecipherable bits, but that’s not true, and it’s the source of ODF relevance. In a nutshell, and despite its extension, any ODF file is nothing more than a standard ZIP archive of a few folders and files, for the most part formatted in the very verbose but plain text eXtensible Markup Language, or XML for short.

Figure 1: A simple ODF text document template, created with LibreOffice, that contains only the placeholders for the text and images to be replaced automatically.

To learn how ODF works in the simplest and shortest possible way, let’s start from Figure 1 (above), which shows the template file created with LibreOffice as the starting point for our practical example. It’s a one-page text, containing just placeholders for a title, a paragraph of text, and finally an image, which for consistence is a screenshot of an IMAGE_HERE string, but could be anything you want, as long as it’s an image. The example will show how fewer than 30 lines of code can clone that file countless times, replacing TITLE_HERE, TEXT_HERE and the image with different texts and images each time.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
May 2025
VIEW IN STORE

Other Articles in this Issue


LINUX FORMAT
LINUX FORMAT
The #1 open source mag Future Publishing Limited,
WELCOME
MEET THE TEAM
This issue, we’re all about taking Linux on the move, so what is the oddest place where you’ve found yourself using Linux?
Linux on the move
Just as Windows Mobile wasn’t Windows, and Apple’s
REGULARS AT A GLANCE
Rust drama gets more corrosive
KERNEL
Firefox T&Cs revision sparks controversy
Mozilla tries to back-pedal after backlash to changes concerning ownership and resale of user data.
Steam beats Amazon
Amazon’s gaming ambitions fail to topple Steam.
SOVEREIGN STANDARDS
OPINION
STABLE STORAGE
OPINION
Chromium loses uBlock Origin
Google’s Manifest V3 pushes users to alternative, less powerful ad blockers.
Brother firmware kerfuffle
Brother denies blocking third-party ink cartridges.
Matrix could shut down
Hosted bridges face imminent closure unless urgent funding is secured.
Distro watch
What’s behind the free software sofa?
ZINK OR SWIM
OPINION
RUST BUCKET
OPINION
Kernel Watch
Jon Masters summarises the latest happenings in the Linux kernel, so that you don’t have to.
ONGOING DEVELOPMENT
Confidential Compute patches continue to hit the kernel
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
Wise-Fise I just read through the last edition
Helpdex
shane_collinge@yahoo.com
LETTER OF THE MONTH
AI AI oh!
FreeFileSync
Version: 14.0 Web: https://freefilesync.org
GPU Screen Recorder
Version: 5.1.4 Web: https://git.dec05eba.com/gpu-screen-recorder
Picocrypt
Version: 1.46 Web: https://github.com/Picocrypt/Picocrypt
Vieb
Version: 12.2.0 Web: https://vieb.dev
Beaver Notes
Version: 3.9.0 Web: https://beavernotes.com
Ignition
Version: 1.1.1 Web: https://github.com/flattool/ignition
Gaia Sky
Version: 3.6.6 Web: https://zah.uniheidelberg.de/gaia/outreach/gaiasky
ET: Legacy
Version: 2.83.2 Web: www.etlegacy.com
PySolFC
Version: 3.2.0 Web: https://pysolfc.sourceforge.io
Darktable
Version: 5.0.1 Web: www.darktable.org
Tangram
Version: 3.3 Web: https://apps.gnome.org/Tangram/
INSTALL UBUNTU!
How fast can you install Ubuntu 25.04? Take our challenge and beat our install speed demons!
REVIEWS
Nvidia GeForce RTX 5090
There’s anew king in town, same as the last, says Jarred Walton
Netrunner 25
Nate Drake catches the latest Netrunner just in time. Will this Debian-based distro be able to keep up with his demands?
NuTyX 25.02.5
Nate Drake is crossing the Channel with this independently developed French Linux distro inspired by LFS. Will he sink or swim?
Rhino Linux 2025.2
Nate Drake takes the Rhino by the horns to discover whether this Ubuntu-based rolling distro is worth charging up.
Tails 6.12
Nate Drake dives into the murky world of the darknet with this Debian-based distro that routes connections through Tor.
Dwarf Fortress – Steam
Imploring Management not to tunnel too far, Lincoln Carpenter fears they’ll dig too greedily and too deep, and awake what lies in the darkness.
ROUNDUP
Ubuntu spin-offs
Michael Reed examines five desktop distributions that use Ubuntu as a base and take things off in five unique directions.
Installation
The first job is to get the distro up and running.
First-run experience
A first run needs useful signposting, particularly for beginners.
Desktop design and use
The base home environment.
Support and community
When you get stuck, can you get help?
Quality of documentation
Where these distros differ from Ubuntu, what information is available?
Adding software
The built-in applications will get you started, but you’ll always have to add more.
Base software
Included apps and utilities steer the distro in an initial direction.
Ubuntu spin-offs
he Linux Mint desktop doesn’t attempt to reinvent
MAKE LINUX MOBILE
MAKE LINUX MOBILE
Your Android phone is supporting the Google empire. Jonni Bidwell wants to help set it free, through the wonders of open source.
Android problems…
There are privacy, security, philosophical and environmental reasons to FOSSify your phone. As well as plain whimsy.
Reasons to deGoogle
It’s difficult to see where the free bits of Android stop and the Googley bits begin, so allow us to elucidate.
Installing LineageOS
Time to take off the gloves and jump straight into freeing your phone. It’s time to install LineageOS.
Full-fat mobile Linux
For that full Linux experience, we take a look at two of the finest non-Android mobile OSes – Ubuntu Touch and PostmarketOS,
Pi USER
The Pi 5 gets pseudo interlace support
Your old CRT can keep on ticking with a bit of digital magic.
The Argon40 Upton One laptop
Case maker expands into Pi-powered laptops.
DEEPSEEK SLOW DIVING
Les Pounder works with groups such as the
AlmaLinux 9.5
Les Pounder takes a look at a stunning Linux distro that offers a clean user interface, and is snappy even on a Raspberry Pi 5 4GB.
Argon One V5
If Scotty had a Raspberry Pi, he would probably also have this case to put it in, ponders Les Pounder.
Control a world of lights with CheerLights
Bringing cheer and joy wherever he goes, Les Pounder once again creates an illuminating project with a global reach.
IN DEPTH
Into the BLACKWELL
What lurks at the bottom of Nvidia’s deepest GPU technology? Jarred Walton is our man for technological spelunking.
TUTORIALS
Draw in the terminal
Shashank Sharma’s takeaway from years of writing is that if it’s to be done, it can be done from the terminal.
Safe and secure backups to any cloud
Nick Peers takes a deep dive into Duplicati, a backup tool that ensures anything you store in the cloud remains completely private.
Custom open source health monitoring
Deciding to spy on himself for once, Michael Reed examines the ways we can keep a record of our activities using various pieces of software.
The hardware that made Linux great
Part Two! Don’t miss part three in next month’s issue!
Upgrade it: Home hobbyist 3D printers
Amateur wanderer, part-time teacher and hardcore 3D printerist Alastair Jennings offers his advice for those looking to buy.
Creality K1C
High-quality prints and superb material choice.
Original PRUSA MK4S
Serious about 3D printing? This is a beast.
Anycubic Kobra S1 Combo
Great for accurate multi-filament 3D printing
Snapmaker Artisan
A very versatile machine for hobbyists.
QIDI Plus4
Perfect for those do-it-yourself home improvements.
Anycubic Photon Mono M7 Pro
Top pick for finely detailed 3D printing.
HACKING ACADEMY
HACKING SKILLS AND THRILLS
Nate Drake is a technology journalist specialising in
GitHub hides malware disguised as games
Threat actors are targeting children with new campaign.
Badbox is back!
Million devices affected.
Malvertising
GitHub involved again.
N600 (PAU09) Wi-Fi N USB
Nate Drake heads up to the roof to test whether Panda’s Wi-Fi adaptor offers the best range and performance for budding hackers.
Juicing your hacks up
JUICE SHOP
Kali Linux laid bare
Nate Drake speaks to two of the leading lights of the most famous Linux hacking distro of all time.
CODING ACADEMY
Coding Cosmic Invaders in BBC Basic
Nate Drake invites you to stave off the alien menace by coding your very own Space Invaders clone in Basic, because it’s 2025!
Quickly evaluate poker hands in Rust
David Bolton introduces some more Rust concepts and explains how his poker hand evaluation program works.
ADVERTISEMENT
LINUX FORMAT
GAMES RADAR
WWW.GAMESRADAR.COM
LINUX FORMAT
www.magazinesdirect.com
LINUX FORMAT
magazinesdirect.com
TECHRADAR
www.techradar.com
MAGAZINES DIRECT
magazinesdirect.com
MAGAZINES DIRECT
magazinesdirect.com
TOM'S hardware
MAGAZINES DIRECT
magazinesdirect.com
CODE CLUB
www.codeclub.org.uk
EFF
EFF.ORG
GO COMPARE
Chat
X
Pocketmags Support