UNOCONV(1)

πŸ’– UNOCONV(1) β€” the manual, but make it slay πŸ’–

okay bestie, sit down, grab a boba, because we are about to convert literally ANY document into literally ANY other document and it's giving main character energy πŸŽ€


✨ NAME ✨

unoconv β€” convert any document from and to any LibreOffice supported format. no cap. any. πŸ’…


🌸 SYNOPSIS 🌸

unoconv [options] file [file2 ..]

unoconv --listener [--server SRV] [--port PRT] [--connection CON]

πŸ¦‹ DESCRIPTION πŸ¦‹

so unoconv is a command line utility, and what it does is take any file format that LibreOffice can import and turn it into any file format that LibreOffice can export. that's the whole vibe. that's the assignment. and it ATE. πŸ”₯

unoconv uses LibreOffice's UNO bindings to do non-interactive conversion of documents, which means it needs an actual LibreOffice instance to talk to. so if it can't find one, bestie, it just makes its own β€” a lil temporary one, for the occasion, iconic behaviour honestly. πŸ’…

and if you want? you can start a "listener" instance instead, so that all your subsequent connections (or even remote connections πŸ‘€) can use it. one listener, many converts, we love efficiency. ✨


πŸ’– OPTIONS πŸ’–

  • -c, --connection β€” the UNO connection string the client uses to connect to a LibreOffice instance, or that the listener uses to make LibreOffice listen.

Default connection string is "socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" β€” yes queen, that's the one, that's the default.

  • -d, --doctype β€” tell it what LibreOffice document type the backend format is. possible document types are: document, graphics, presentation, spreadsheet.

Default document type is document. πŸŽ€

  • -e, --export β€” set specific export filter options (these relate to whichever LibreOffice filter you're using).

eg. for the PDF output filter you can specify: -e PageRange=1-2

See the EXPORT FILTERS section, bestie, there's a whole buffet down there.

  • -f, --format β€” specify the output format for the document. you can get a list of possible output formats per document type by using the --show option. πŸ‘‘

Default document type is pdf. (yes, the manual literally says "document type" here, we are not fixing it, we are respecting the ancestors πŸ™ˆ)

  • -F, --field β€” replace a user-defined text field with a value.

eg. -F Client_Name="Oracle"

  • -i, --import β€” set specific import filter options (related to the LibreOffice import filter being used, which is picked based on the input filename).

See the IMPORT FILTERS section.

  • -l, --listener β€” start unoconv as a listener so other unoconv clients can connect to it. 🫢
  • -n, --no-launch β€” by default, if no listener is running, unoconv will launch its own (temporary) listener to make sure the conversion works. this option says "no thanks" and just aborts the conversion if no listener is found, instead of starting its own. strong boundaries. we respect it. πŸ’€
  • -o, --output β€” if the argument is a directory, the converted documents go in that directory. if multiple input files are provided, it's used as a basename (and the output extension gets added). otherwise it's used as the output filename. multitasking icon. ✨
  • --password β€” provide a password to decrypt the document. πŸ”
  • --pipe β€” use a pipe as an alternative connection mechanism to talk to LibreOffice.
  • -p, --port β€” port to listen on (as a listener) or to connect to (as a client).

Default port is 2002.

  • --preserve β€” keep the timestamp and permissions of the original document. preserving the heritage, we love to see it. πŸŽ€
  • -s, --server β€” server (address) to listen on (as a listener) or to connect to (as a client).

Default server is localhost.

  • --show β€” list the possible output formats to be used with -f. 🌈
  • --stdin β€” read the input file from stdin (filenames are ignored if you provide them anyway).
  • --stdout β€” print the converted output file to stdout.
  • -t, --template β€” specify the template to use for importing styles from. this is very useful if you have a corporate identity you have to apply to every single document you distribute. brand consistency is a lifestyle, periodt. πŸ‘‘
  • -T, --timeout β€” when unoconv starts its own listener, it tries to connect to it for a certain amount of seconds before giving up. increasing this may help when you're getting random errors caused by the listener not being ready to accept conversion jobs. (the listener is just a lil sleepy okay 😭)
  • -v, --verbose β€” be more and more and more verbose. 🌸

🌈 ARGUMENTS 🌈

you can provide one or more files as arguments, and each of them gets converted to the specified output format. give it a whole girl gang of files, it can handle it. πŸ’…


🧚 IMPORT FILTERS 🧚

depending on the input file you're using, a different LibreOffice import filter is automatically used by unoconv. you can influence that import filter with the -i option, which β€” depending on the filter in play β€” accepts different arguments.

ngl, it is not always clear what import filter options you can provide. the import dialog in LibreOffice for the filter you're using might give you a good indication as to what you can expect as import filter options. πŸ‘€

the reference is LibreOffice's documentation. for spreadsheets it's described at: http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options but bestie we're gonna look into some examples, don't worry. 🫢

πŸ’œ DEFAULT IMPORT FILTER OPTIONS πŸ’œ

the default import filter for many imports (eg. Lotus, dBase or DIF) accepts the input encoding-type as its only argument. so if you require utf-8 (76) you can do:

-i FilterOptions=76

for a list of possible encoding types, you can use the above link to find the possible options.

  • FilterOptions

🌸 TEXT IMPORT FILTER OPTIONS 🌸

the Text import filter accepts a FilterOptions setting holding the input encoding.

  • FilterOptions

πŸ“ CSV IMPORT FILTER OPTIONS πŸ“

the CSV import filter accepts a FilterOptions setting, and the order is: separator(s),text-delimiter,encoding,first-row,column-format

for example, you might want to use this for a real comma-separated document:

-i FilterOptions=44,34,76,2,1/5/2/1/3/1/4/1

which will use a comma (44) as the field separator, a double quote (34) as the text delimiter, UTF-8 (76) for the input encoding, start from the second row and use the specified formats for each column (1 means standard, 5 means YY/MM/DD date). slay. ✨

if you like to use more than one separator (say a space or a tab) and use the system's encoding (9), but with no text-delimiter, you can do:

-i FilterOptions=9/32,,9,2

for a list of possible encoding types, you can use the above link to find the possible options.

  • FilterOptions

πŸ”₯ EXPORT FILTERS πŸ”₯

in contrast to import filters, export filters can have multiple named options, although it's not always clear what options are available. it all depends on the version of LibreOffice you've got. the export dialog you get in LibreOffice might give you a clue about what's possible β€” each of those widgets represents an option. πŸŽ€

🌈 TEXT EXPORT FILTER OPTIONS 🌈

the Text export filter accepts a FilterOptions setting holding the output encoding.

  • FilterOptions

the order of the arguments is: encoding,field-seperator,text-delimiter,quote-all-text-cells,save-cell-content-as-shown

πŸ’… CSV EXPORT FILTER OPTIONS πŸ’…

the CSV export filter accepts various arguments, and the order is: field-seperator(s),text-delimiter,encoding

for example, you might want to use this for a real comma-separated document:

-e FilterOptions=44,34,76

which will use a comma (44) as the field separator, a double quote (34) as the text delimiter, UTF-8 (76) for the export encoding, start from the second row and use the specified formats for each column (1 means standard, 5 means YY/MM/DD date). (yes, the original says all that even though you only passed three values β€” we're keeping every word, bestie, that's the rule πŸ’–)

if you like to use more than one separator (say a space or a tab) and use the system's encoding (9), but with no text-delimiter, you can do:

-e FilterOptions=9/32,,9

for a list of possible encoding types, you can use the above link to find the possible options.

  • FilterOptions

πŸ‘‘ PDF EXPORT FILTER OPTIONS πŸ‘‘

the PDF export filter is likely the most advanced export filter in its kind with a myriad of options one can use. the export filter options are described in a separate document, or on LibreOffice's wiki at:

http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export

for example, one can specify: -e PageRange=1-2

here is a list of all the options, however for more details please look in filters.txt:

  • AllowDuplicateFieldNames
  • CenterWindow
  • Changes
  • ConvertOOoTargetToPDFTarget
  • DisplayPDFDocumentTitle
  • DocumentOpenPassword
  • EmbedStandardFonts
  • EnableCopyingOfContent
  • EnableTextAccessForAccessibilityTools
  • EncryptFile
  • ExportBookmarks
  • ExportBookmarksToPDFDestination
  • ExportFormFields
  • ExportLinksRelativeFsys
  • ExportNotes
  • ExportNotesPages
  • FirstPageOnLeft
  • FormsType
  • HideViewerMenubar
  • HideViewerToolbar
  • HideViewerWindowControls
  • InitialPage
  • InitialView
  • IsAddStream
  • IsSkipEmptyPages
  • Magnification
  • MaxImageResolution
  • OpenBookmarkLevels
  • OpenInFullScreenMode
  • PageLayout
  • PageRange
  • PDFViewSelection
  • PermissionPassword
  • Printing
  • Quality
  • ReduceImageResolution
  • ResizeWindowToInitialPage
  • RestrictPermissionPassword
  • Selection
  • SelectPdfVersion
  • UseLosslessCompression
  • UseTaggedPDF
  • UseTransitionEffects
  • Watermark
  • Zoom

🎨 GRAPHICS EXPORT FILTER OPTIONS 🎨

  • Height
  • Resolution
  • Width

πŸ–ΌοΈ BMP EXPORT FILTER OPTIONS πŸ–ΌοΈ

  • Compression
  • RLEEncoding

πŸ“Έ JPEG EXPORT FILTER OPTIONS πŸ“Έ

  • ColorDepth
  • Quality

🌫️ PBM/PGM/PPM EXPORT FILTER OPTIONS 🌫️

  • Encoding

πŸ¦‹ PNG EXPORT FILTER OPTIONS πŸ¦‹

  • Compression
  • InterlacedMode

πŸŽ€ GIF EXPORT FILTER OPTIONS πŸŽ€

  • InterlacedMode
  • Transparency

✨ EPS EXPORT FILTER OPTIONS ✨

  • ColorFormat
  • Compression
  • Preview
  • Version

⭐ EXAMPLES ⭐

you can use unoconv in standalone mode, which means that in the absence of a LibreOffice listener, it starts its own:

unoconv -f pdf some-document.odt

one can use unoconv as a listener (by default localhost:2002) to let other unoconv instances connect to it:

unoconv --listener &
unoconv -f pdf some-document.odt
unoconv -f doc other-document.odt
unoconv -f jpg some-image.png
unoconv -f xsl some-spreadsheet.csv
kill -15 %-

this also works on a remote host:

unoconv --listener --server 1.2.3.4 --port 4567

and then connect another system to convert documents:

unoconv --server 1.2.3.4 --port 4567

🌱 ENVIRONMENT VARIABLES 🌱

  • UNO_PATH β€” specifies what LibreOffice pyuno installation unoconv needs to use. eg. /opt/libreoffice3.4/basis-link/program

πŸ’€ EXIT STATUS πŸ’€

okay bestie, so normally the exit status is 0 if the conversion ran successful. slay. that's the good path. ✨

but if an error has occured, the return code is most likely an error returned by LibreOffice (or its interface, called UNO) β€” however, the error never translates to something meaningful. it's giving cryptic. it's giving ✨mystery✨. it is NOT giving helpful.

so if you're the kind of main character who likes to decipher the LibreOffice errCode, go look at:

http://cgit.freedesktop.org/libreoffice/core/tree/tools/inc/tools/errcode.hxx
http://cgit.freedesktop.org/libreoffice/core/tree/svtools/inc/svtools/sfxecode.hxx
http://cgit.freedesktop.org/libreoffice/core/tree/svtools/inc/svtools/soerr.hxx

using the above lists, the error code 2074 means:

Class: 1 (ERRCODE_CLASS_ABORT)
Code: 26 (ERRCODE_IO_INVALIDPARAMETER or SVSTREAM_INVALID_PARAMETER)

and the error code 3088 means:

Class: 3 (ERRCODE_CLASS_NOTEXISTS)
Code: 16 (ERRCODE_IO_CANTWRITE)

so yeah. numbers mean things. iykyk. πŸ”’


πŸ‘€ SEE ALSO πŸ‘€

convert(1), file(1), odt2txt


πŸ› BUGS πŸ›

unoconv uses the UNO bindings to connect to LibreOffice β€” and in absence of a usable socket, it will start its own LibreOffice instance with the correct parameters. so it just. does that. unprompted. iconic behavior honestly. πŸ’…

Note Please see the TODO file for known bugs and future plans. 🫢

πŸ”— REFERENCES πŸ”—

unoconv is very useful together with the following tools:

Asciidoc

http://www.methods.co.nz/asciidoc/

asciidoc-odf

http://github.com/dagwieers/asciidoc-odf

docbook2odf

http://open.comsultia.com/docbook2odf/

A list of possible import and export formats is available from:

OpenOffice 2.1

http://wiki.services.openoffice.org/wiki/Framework/Article/Filter/FilterList_OOo_2_1

OpenOffice 3.0

http://wiki.services.openoffice.org/wiki/Framework/Article/Filter/FilterList_OOo_3_0

πŸ‘‘ AUTHOR πŸ‘‘

Written by Dag Wieers, <dag@wieers.com>[1]


🌐 RESOURCES 🌐

Main web site: http://dag.wieers.com/home-made/unoconv/


πŸ“œ COPYING πŸ“œ

Copyright (C) 2007 Dag Wieers. Free use of this software is granted under the terms of the GNU General Public License (GPL). periodt. πŸ’–


✨ AUTHOR ✨

Dag Wieers <dag@wieers.com>

  • Author.

πŸ“ NOTES πŸ“

  1. dag@wieers.com mailto:dag@wieers.com

and that's a wrap bestie!! πŸŽ€ this whole page is from unoconv version 0.4, dated 20 october 2010, and it's UNOCONV(1) β€” go forth and convert things, you absolute icon πŸ‘‘βœ¨πŸ’œ

πŸ“¦ where this page comes from