salazarysanchez

Mejoremos el mundo y nuestras vidas un Hack a la vez.

Convertir odt/ods en pdf con LibreOffice desde terminal

Por Osvaldo, 2014-04-28 02:48

En Libreoffice, desde antes que lo implementaran en Microsoft Office, se puede guardar el documento de trabajo en formato pdf (sigla del inglés portable document format) con solo presionar un icono.

Ayer me surgió la pregunta: “¿Se podrá desde terminal hacer lo mismo?”. La lógica apuntaba a que si se podía.

Buscando en la terminal, escribí el clásico comando man en la terminal de mi Debian (donde X.X es la versión de LibreOffice instalada):

$ man libreofficeX.X

con lo que obtuve:

No manual entry for libreofficeX.X
See 'man 7 undocumented' for help when manual pages are not available.

La lógica me indicó buscar la ayuda, y como no la obtuve por man lo intenté con el siguiente comando:

$ libreofficeX.X -h

con lo que obtuve:

LibreOffice X.X 89ea49ddacd9aa532507cbf654f2bb22b1

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

Options:
- -minimized keep startup bitmap minimized.
- -invisible no startup screen, no default document and no UI.
- -norestore suppress restart/restore after fatal errors.
- -quickstart starts the quickstart service
- -nologo don\'t show startup screen.
- -nolockcheck  don\'t check for remote instances using the installation
- -nodefault don\'t start with an empty document
- -headless like invisible but no userinteraction at all.
- -help/-h/-? show this message and exit.
- -version display the version information.
- -writer create new text document.
- -calc create new spreadsheet document.
- -draw create new drawing.
- -impress create new presentation.
- -base create new database.
- -math create new formula.
- -global create new global document.
- -web create new HTML document.
-o open documents regardless whether they are templates or not.
-n always open documents as new files (use as template).

- -display <display>
Specify X-Display to use in Unix/X11 versions.
-p <documents...>
print the specified documents on the default printer.
- -pt <printer> <documents...>
print the specified documents on the specified printer.
- -view <documents...>
open the specified documents in viewer-(readonly-)mode.
- -show <presentation>
open the specified presentation and start it immediately
- -accept=<accept-string>
Specify an UNO connect-string to create an UNO acceptor through which
other programs can connect to access the API
- -unaccept=<accept-string>
Close an acceptor that was created with --accept=<accept-string>
Use --unnaccept=all to close all open acceptors
- -infilter=<filter>
Force an input filter type if possible
Eg. --infilter=\"Calc Office Open XML\"
- -convert-to output_file_extension[:output_filter_name] [- -outdir output_dir] files
Batch convert files.
If - -outdir is not specified then current working dir is used as output_dir.
Eg. - -convert-to pdf *.doc
- -convert-to pdf:writer_pdf_Export - -outdir /home/user *.doc
- -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
- -pidfile file
Store soffice.bin pid to file.

Remaining arguments will be treated as filenames or URLs of documents to open.

Leyendo a detalle lo anterior, use lo siguiente:

$ libreofficeX.X - -headless - -convert-to pdf "Propuesta trabajo.odt"

Con lo que obtuve un documento Propuesta trabajo.pdf de un archivo creado con writer. Buen resultado obtuve al convertir una hoja de calculo a pdf con:

$ libreofficeX.X - -headless - -convert-to pdf "Presupuesto.ods"

No tuve ningun problema en convertir a pdf archivos con extensión .doc, .xls, .docx y .xlsx

Espero les sea de utilidad como lo fue para mi :D

Éste sitio es un fork de MovimientoLibre.
El contenido de las entradas está bajo la licencia CC BY-SA.
El programa está protegido por la licencia GPL versión 2.
La documentación está protegida por la licencia GFDL.