Question
Is there any way to specify to libreoffice
, via commandline, to use Cambria
for occurences of Calibri
in the PDF generation without the need of any user-interaction?
Context
I am using this command:
libreoffice --headless --invisible --convert-to pdf --outdir images/output/ images/Mockups.pptx
or this one:
unoconv -f pdf -o images/output/ images/Mockups.pptx
to automatically convert a PPTX
to PDF
in a virtualbox
machine launched with vagrant
running ubuntu/trusty64
.
Vagrantfile:
config.vm.box = "ubuntu/trusty64"
[...]
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y unoconv imagemagick default-jdk ant docbook-xsl fop libxml2-utils xsltproc php5-cli
SHELL
The original pptx
is edited by people using windows and uses the Calibri
font. I can't require them to use different settings or fonts.
As the Calibri
font is not in the trusty
distribution, the PDF
conversion done by the libreoffice
messes the layout.
I've read Cambria
is metric-equivalent to Calibri
.
So, as stated, the question is how to instruct libreoffice
for a certain font substitution via command line.
We had a similar issue with LibreOffice under Alfresco (which also runs headless). Installing the ChromeOS fonts packages for Carlito (Calibri equivalent) and Caladea (Cambria equivalent) fixed it, using a hint from here: https://wiki.debian.org/SubstitutingCalibriAndCambriaFonts. Changing the mappings within LO did nothing, neither on the headless nor on the desktop - only installing the packages solved it. (For completeness, we had added the entries for the mappings to the LO registrymodifications.xcu and that achieved nothing, on either platform - editing the files under conf.d takes precedence, it seems).
Packages installed were:
Note: $ below is the system prompt...
Linux:
FreeBSD: (Hint:do the search first as name may change over time)
You may need to run:
Check with:
Works perfectly now.
These installs create the following files which give the desired font substitutions (depending on your platform):
Linux (Ubuntu 14.x):
These are linked from /etc/fonts/conf.d like so:
FreeBSD (10.x):
...linked ala...
The
pptx
file format is just a zip file with a different extension, you could try unzipping it and doing a text substitution: