Printing ODT documents from the command line (and mass PDF exporting)

I recently had to print a collection of documents I had created over the year and I really was not thrilled at the prospect of having to open the file, Command+P, Enter, Command+W, Command+Tab, open new document, rinse, repeat for some 60 odd documents. All the documents in question were ODT documents created using either OpenOffice or LibreOffice, depending on how old they were.

A bit of research on command-line printing using OpenOffice and LibreOffice led me to some outdated posts that didn't quite give me the information I was looking for, but gave me a good place to start: the Writer application's binary is named 'soffice' and accepts various command-line arguments. A quick search revealed that the file does indeed exist inside the OS X application file:

$ find /Applications/LibreOffice.app -name soffice
/Applications/LibreOffice.app/Contents/MacOS/soffice

(for those that don't know, OS X applications are actually just plain folders that hold the application's metadata, executables and related files)

What's even better is that LibreOffice now has an option to do exactly what I was looking for:

$ /Applications/LibreOffice.app/Contents/MacOS/soffice -h
LibreOffice 3.5

Usage: soffice [options] [documents...]

Options:
--minimized    keep startup bitmap minimized.
[...]
--print-to-file [-printer-name printer_name] [--outdir output_dir] files
      Batch print files to file.
      If --outdir is not specified then current working dir is used as output_dir.
      Eg. --print-to-file *.doc
          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc

Using the "--print-to-file" parameter will convert any document that LibreOffice can read into a raw postscript file by the same name.

Although I could easily send the resulting PostScript files to the printer using CUPS' lp utility, I wanted to take this one step further. Each of these documents contained the same colour logo and I wanted to avoid wasting any ink. Another search brought me to this question on SuperUser.com, where ysis's answer demonstrated that the gs (GhostScript) utility can do this and even merge all the documents into one file:

gs -sOutputFile=converted.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibiltyLevel=1.4 -dNOPAUSE -dBATCH input1.ps input2.ps input3.ps

After about 30 seconds of processing all of the 60 files were there, in blank and white, concatenated into converted.pdf. Printed it using OS X's Preview application using the "fast draft" setting and I had all my 60 documents printed with minimal ink used in less than 5 minutes!

Rating: 

Comments

I'm trying to follow your instructions, but my commands aren't working. Could you paste the literal command that you used successfully? e.g. this command doesn't work for me: libreoffice --print-to-file * --outdir ps/

Hi Sam,

I'm not sure what platform you're on, but it may be necessary to replace libreoffice in the command with LibreOffice's specific binary corresponding to LibreOffice Writer (on OS X, that's soffice).

I also remember experimenting with its other batch options (possibly --outdir) and remember having problems. In my case it was simplest to simply use something like this:

/Applications/LibreOffice.app/Contents/MacOS/soffice --print-to-file container-folder/*.odt

and then grab mass move the .ps files to another folder:
mkdir new_ps_files
find . -name '*.ps' | while read line;do
  mv "$line" new_ps_files
done

Why can’t you try to use other alternative procedures in order to get the files you want to work on? Like the older ways of inserting floppy disk or the compact disk for PDF exporting. Just give a try at http://topaussiewriters.com/assignmentprovider-aus-com-review/ to get more clear cut view on how to work with the best procedures available online.

Gucci replica handbags customization services to further optimize the brand's personalized concept and the pursuit of detail. The service will be customized according to customer's wishes and details of leather materials for customers to create their own New Bamboo handbags, New Jackie handbags, or Stirrup handbags. Designed by Gucci's creative director, the iconic collection of handbags, through prada replica handbags exclusive custom service, based on customer wishes to freely choose a variety of rare leather, as well as a variety of different color combinations, and further create unique to each customer's unique style, Highlighting the brand "personalized luxury" tradition. Each custom louis vuitton replica is craftsman fine craftsmanship and handmade technology products. Metal texture or matte effect; metal details, the signature Spurs decorative and other metal accessories, a light gold, light silver or retro gold and retro silver, and other options ; These materials and color combinations can be based on customer preferences.

Online writing services are the finest choices to learn the new writing techniques and they open a world of creativity in front of students. Students always need help from experts to score high grades in their academic paper. They believe essay writing service, dissertation writing service etc are the best options to ask for help.Visit our site.

Online writing services are the finest choices to learn the new writing techniques and they open a world of creativity in front of students. Students always need help from experts to score high grades in their academic paper. They believe essay writing service, dissertation writing service etc are the best options to ask for help. Best Essay Writing Service Visit our site.

I liked the information you have.View this site Write My Essays as the data available will give you a helping hand when you agree to order essays online and to achieve the highest results when it comes to custom essay writing service.