Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

FWIW, I came up with my own solution for this (at least until a better one is found). I wrote a script that unzips the docx file and uses xmlstarlet to change the fonts in styles.xml (then re-zips). This is working fine even if not the "cleanest" solution. Here's what it looks like (in case it's helpful to anyone):

#!/bin/bash

FN="resume.docx"
TMP="xx"

function fail() { echo "error: $*"; exit 1; }

[ -e $FN ] || fail "$FN not found"

WD=$PWD
function cleanup()
{
    cd "$WD"
    [ -e $TMP ] && rm -rf $TMP >/dev/null
}
trap cleanup EXIT
set -e

mkdir $TMP
cd $TMP
unzip -q ../$FN
cd word
xmlstarlet ed -u '//@w:ascii|//@w:hAnsi' -v 'Courier New' styles.xml > newstyles.xml
mv newstyles.xml styles.xml
cd ..
rm ../$FN
zip -rq ../$FN *

FWIW, I came up with my own solution for this (at least until a better one is found). I wrote a script that unzips the docx file and uses xmlstarlet to change the fonts in styles.xml (then re-zips). This is working fine even if not the "cleanest" solution. Here's what it looks like (in case it's helpful to anyone):

#!/bin/bash

FN="resume.docx"
FN="myfile.docx"
TMP="xx"

function fail() { echo "error: $*"; exit 1; }

[ -e $FN ] || fail "$FN not found"

WD=$PWD
function cleanup()
{
    cd "$WD"
    [ -e $TMP ] && rm -rf $TMP >/dev/null
}
trap cleanup EXIT
set -e

mkdir $TMP
cd $TMP
unzip -q ../$FN
cd word
xmlstarlet ed -u '//@w:ascii|//@w:hAnsi' -v 'Courier New' styles.xml > newstyles.xml
mv newstyles.xml styles.xml
cd ..
rm ../$FN
zip -rq ../$FN *