Office to pdf linux

How can I convert an ODT file to a PDF?

You can also use the command-line of libreoffice for your purpose. That gives you the advantage of batch conversion. But single files are also possible. This example converts all ODT files in the current directory to PDF:

libreoffice --headless --convert-to pdf *.odt 

Get more information on command-line options with:

Thi9s works, but it has a problem: if the GUI is open the command will do nothing (not even show an error). Ugly, but with this workaround you can open a new instance: —env:UserInstallation=file:///path/to/some/directory .

I managed to get batch conversion with unoconv as well. For example I used the line unoconv -f pdf *.ppt successfully.

for those wondering what is pros and cons of Unoconv vs Libreoffice command line, this issue might help: github.com/dagwieers/unoconv/issues/364

The man page says for —convert-to that » It implies —headless «. Thus libreoffice —convert-to pdf *.odt should work as well (for version 5.1.6.2 at least).

Just open the document with libre office and choose Export as PDF. :

enter image description here

For a command line solution there is unoconv that converts files from the command line:

unoconv -f pdf mydocument.odt 

Note: unoconv depends on Libre Office.

for those wondering what is pros and cons of Unoconv vs Libreoffice command line, this issue might help: github.com/dagwieers/unoconv/issues/364

@Takkat unoconv does not seem to find libreoffice5 location on MacOS Sierra, it says unoconv: Cannot find a suitable office installation on your system. , therefore it’s unusable 🙁

Here are a few more details about the «non-GUI» method.

  1. You can use this method not only to convert ODT files to PDF. It will also work for MS Word DOCX files (it will work as well as LibreOffice is able to handle the particular ODT), and, in general all file types which LibreOffice can open.
  2. I do not think that there is a binary named libreoffice as one of the other answers suggested. However, there is soffice(.bin) — the binary that can be used to start LibreOffice from the command line. It is usually located in /usr/lib/libreoffice/program/ ; and very often, a symlink /usr/bin/soffice points to that location.
  3. Then, in most cases the parameters —headless —convert-to pdf are not sufficient. It needs to be:
--headless --convert-to pdf:writer_pdf_Export 
 "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_$" 
/path/to/soffice \ --headless \ "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_$" \ --convert-to pdf:writer_pdf_Export \ --outdir $/lo_pdfs \ /path/to/test.docx 
$ /path/to/libreoffice -h # if that path exists, which I doubt! $ /path/to/soffice -h $ /path/to/soffice.bin -h 
  • Do you get an output here?
  • For which one of the three binaries/symlinks?
  • Record the outputs.
  • Tell us your outputs.

Compare them to the command line you used:

For comparison, my own (Mac OS X) output is here:

 $ /Applications/LibreOffice.app/Contents/MacOS/soffice -h LibreOffice 5.1.2.2 d3bf12ecb743fc0d20e0be0c58ca359301eb705f 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 user interaction 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 Specify X-Display to use in Unix/X11 versions. -p print the specified documents on the default printer. --pt  print the specified documents on the specified printer. --view open the specified documents in viewer-(readonly-)mode. --show open the specified presentation and start it immediately --accept= Specify an UNO connect-string to create an UNO acceptor through which other programs can connect to access the API --unaccept= Close an acceptor that was created with --accept= Use --unnaccept=all to close all open acceptors --infilter=[:filter_options] Force an input filter type if possible Eg. --infilter="Calc Office Open XML" --infilter="Text (encoded):UTF8,LF. " --convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files Batch convert files (implies --headless). 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 --convert-to "html:XHTML Writer File:UTF8" *.doc --convert-to "txt:Text (encoded):UTF8" *.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 --cat files Dump text content of the files to console Eg. --cat *.odt --pidfile=file Store soffice.bin pid to file. -env:[=] Set a bootstrap variable. Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path. Remaining arguments will be treated as filenames or URLs of documents to open. 
--infilter="Microsoft Word 2007/2010/2013 XML" 
--infilter="Microsoft Word 2007/2010/2013 XML" --infilter="Microsoft Word 2007-2013 XML" --infilter="Microsoft Word 2007-2013 XML Template" --infilter="Microsoft Word 95 Template" --infilter="MS Word 95 Vorlage" --infilter="Microsoft Word 97/2000/XP Template" --infilter="MS Word 97 Vorlage" --infilter="Microsoft Word 2003 XML" --infilter="MS Word 2003 XML" --infilter="Microsoft Word 2007 XML Template" --infilter="MS Word 2007 XML Template" --infilter="Microsoft Word 6.0" --infilter="MS WinWord 6.0" --infilter="Microsoft Word 95" --infilter="MS Word 95" --infilter="Microsoft Word 97/2000/XP" --infilter="MS Word 97" --infilter="Microsoft Word 2007 XML" --infilter="MS Word 2007 XML" --infilter="Microsoft WinWord 5" --infilter="MS WinWord 5" 

Источник

Как конвертировать Word (doc) в PDF в Linux?

У меня есть набор файлов в формате .doc , которые необходимо преобразовать в формат .pdf . Я использую Ubuntu Linux.

sudo apt-get install cups-pdf 

Затем перейдите к «Система»> «Администрирование»> «Печать» и создайте новый принтер, установите его в качестве принтера PDF-файла и назовите его «pdf».

oowriter -pt pdf your_word_file.doc 

Теперь вы найдете ваш файл .pdf в ~ / PDF.

sudo apt-get install wv tetex-extra ghostscript wvPDF test.doc test.pdf 

Если пакет tetex-extra недоступен в вашем дистрибутиве, попробуйте texlive-base плюс texlive-latex-base:

sudo apt-get install wv texlive-base texlive-latex-base ghostscript wvPDF test.doc test.pdf 

в oowriter -pt pdf your_word_file.doc , принтер указан? На моем компьютере он будет пытаться печатать на реальном принтере вместо PDF-принтера.

для LibreOffice эта команда lowriter —convert-to pdf your_word_file.doc выводится в текущем каталоге по умолчанию.

oowriter -convert-to pdf:writer_pdf_Export doc_file.doc 

Коротко и просто — однако, если кто-то запускает LibreOffice (или запускает OO.org и не может найти oowriter ) — команда есть swriter -convert-to pdf:writer_pdf_Export x.doc .

На моем Ubuntu 12.04 с LibreOffice по умолчанию мне пришлось использовать lowriter вместо (oo | s |) пишущий. Затем он работал с теми же аргументами , как выше: lowriter -convert-to pdf:writer_pdf_Export file.docx . Файлы .pdf создаются в текущем каталоге.

Мне это нравится. На моем 3.6.6.2 -convert-to pdf выбрал по умолчанию writer_pdf_Export. Также следует иметь в виду, что при запуске этой команды не нужно открывать экземпляры LO, иначе она просто откроет пустой новый документ в графическом интерфейсе. Можно ли этого как-то избежать?

Если вы используете X, то вы можете сделать это через Open Office. Поскольку вы возражаете против того, чтобы делать это вручную, помните, что в Open Office есть несколько хороших макрос-скриптов, которые вы можете автоматизировать . Вы можете сделать что-то подобное с AbiWord (AbiWord —to = pdf).

Если у вас нет X, тогда есть антислово, но оно просто извлекает текст — не выполняет форматирование и графику. Есть также wvWare, который я использовал для массового извлечения изображений из файлов документов, но я никогда не пытался использовать его для преобразования файлов документов в PDF-файлы.

Да, и для файлов .docx может потребоваться что-то другое, но, поскольку они представляют собой просто заархивированные XML-файлы, не составит труда сделать с ними что-то полезное. Для массового извлечения изображений вы просто распаковываете их и копируете каталог с изображениями, но мне никогда не нужно было конвертировать их в Linux.

Источник

How to convert Word (doc) to PDF in linux?

I have a set of files in .doc format, that need to be converted to .pdf format. I am using Ubuntu linux.

10 Answers 10

sudo apt-get install cups-pdf 

Then navigate to System > Administration > Printing and create a new printer, set it as a PDF file printer, and name it as «pdf».

oowriter -pt pdf your_word_file.doc 

Now you’ll find your .pdf file in ~/PDF.

sudo apt-get install wv tetex-extra ghostscript wvPDF test.doc test.pdf 

If the tetex-extra package is not available with your distribution, try texlive-base plus texlive-latex-base:

sudo apt-get install wv texlive-base texlive-latex-base ghostscript wvPDF test.doc test.pdf 

in oowriter -pt pdf your_word_file.doc , is the printer specified? In my computer, it will try to print to an actual printer instead of a pdf printer.

for LibreOffice, the command is lowriter —convert-to pdf your_word_file.doc and the default is to output in the current directory.

oowriter -convert-to pdf:writer_pdf_Export doc_file.doc 

Short and simple — however, if one is running LibreOffice (or is running OO.org and cannot find oowriter ) — the command is swriter -convert-to pdf:writer_pdf_Export x.doc .

On my Ubuntu 12.04 with the default LibreOffice, I had to use lowriter instead of (oo|s| )writer. Then it worked with the same arguments as above: lowriter -convert-to pdf:writer_pdf_Export file.docx . The .pdfs are created in the current directory.

I like this. On my 3.6.6.2 -convert-to pdf chose writer_pdf_Export as default. Also something to keep in mind — don’t have any LO instances open when running this command, otherwise it will just open an empty new document in the GUI. Can this be avoided somehow?

Printing to PDF loses a lot of the document metadata (title, authorship, the headings tree that is used for navigation, and so on).

Install unoconv, convert with: unoconv -fpdf file1.doc file2.doc…

Thanks for the suggestion. But I think the syntax provided by you is wrong. $ unoconv myfile.doc It converts to PDF format by default and so you get myfile.pdf on executing the command.

Agreed that this is the best answer. A better answer however, would be one that was as simple as this, but did not require installing the gigantic libreoffice.

Wow this does a lot more than that. For example you can convert html, doc, docx and more to pdf. For example to convert from html to pdf run unoconv —output output.pdf myHtmlPage.html

If you’re running X then you can do it through Open Office. Since you’re about to object to doing it manually, remember there’s some nice macro scripts in Open Office so you can automate it. You can do something similar with AbiWord (AbiWord —to=pdf).

If you’ve not got X then there is antiword, but that just extracts the text — doesn’t do any formatting or graphics. There’s also wvWare which I’ve used to bulk extract images from doc files, but I’ve never tried using it to convert doc files to pdfs.

Oh and .docx files may well need something different, but since they’re just zipped xml files it shouldn’t be too difficult to do something useful with them. For bulk extracting images you just unzip them and copy the images directory, but I’ve never needed to convert them in Linux.

Источник

Читайте также:  Linux atime ctime mtime
Оцените статью
Adblock
detector