Linux convert pdf to libreoffice

How to convert pdf file to an odt file?

I want to convert a .pdf file to an .odt file so that I can further convert it to a .doc file. Is there any software/script that can do this. I have tried to copy the content of the .pdf file and paste it in LibreOffice Writer but the formatting isn’t preserved. The document is confidential so I’d prefer not to use any on-line service for the conversion. Any help is highly appreciated.

5 Answers 5

You could take a look at PDF Utilities (poppler-utils via Synaptic or apt-get) which includes pdftotext:

Poppler is a PDF rendering library based on Xpdf PDF viewer.

This package contains command line utilities (based on Poppler) for getting information of PDF documents, convert them to other formats, or manipulate them:
* pdfdetach — lists or extracts embedded files (attachments)
* pdffonts — font analyzer
* pdfimages — image extractor
* pdfinfo — document information
* pdfseparate — page extraction tool
* pdftocairo — PDF to PNG/JPEG/PDF/PS/EPS/SVG converter using Cairo
* pdftohtml — PDF to HTML converter
* pdftoppm — PDF to PPM/PNG/JPEG image converter
* pdftops — PDF to PostScript (PS) converter
* pdftotext — text extraction
* pdfunite — document merging tool

Of course, success will depend on how the pdf file was generated. If you get what you want as a text file, you could then save that as an .odt file.

Edit: I forgot to provide the source for the quote. It’s from the description tab in Synaptic for PDF Utilities (based on Poppler).

Источник

Работа LibreOffice в командной строке: конвертирование большого количества файлов и вывод содержимого офисных файлов в консоль

Работа в консоли, если вы в этом разбираетесь, может увеличить вашу производительность. Особенно если это касается большого количества однотипных задач.

Предположим, нам дано множество офисных файлов в формате .doc (или любом другом формате, который поддерживает LibreOffice), и мы хотим их переконвертировать в другой формат. Если файлов немного, то их можно открыть в LibreOffice и выбрать сохранение в нужном формате. Но если их десятки и более, то эта рутинная работа станет долгой и утомительной.

К счастью, LibreOffice умеет работать в консоли. Причём нам даже не нужно писать скрипты, поскольку она понимает подстановочные символы.

Сохранение большого количества файлов в другой формат

Для этого нужно запустить команду

soffice --headless --convert-to doc Имя_файла
  • doc – можно заменить на желаемый формат (pdf, html, odt, docx и т.д.)
  • Имя_файла – замените на тот файл, который вы хотите конвертировать.

Конвертирует все поддерживаемые файлы в каталоге Математика в html формат и сохранит их в текущем каталоге^

soffice --headless --convert-to html Математика/*

Конвертировать все файлы в формате .doc в формат PDF и сохранить их в каталоге /home/user:

soffice --headless --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc

Конвертировать все файлы в формате .doc в формат html с кодировкой UTF8 и сохранить их в текущем каталоге.

soffice --headless --convert-to "html:XHTML Writer File:UTF8" *.doc

Конвертировать все файлы в формате .doc в обычный текст с кодировкой UTF8.

soffice --headless --convert-to "txt:Text (encoded):UTF8" *.doc

Вывод содержимого файла в консоль

Иногда нужно, чтобы консольный Bash скрипт прочитал содержимое офисного файла и вывел это содержимое в консоль. Если бы нас интересовали обычные текстовые файлы, то мы могли бы воспользоваться командой cat. Но офисные файлы имеют сложную структуру и иногда представляют собой архивы, т.е. бинарные файлы. Поэтому для этого у LibreOffice есть специальная опция командной строки —cat:

soffice --headless --cat имя_файла

Конечно, сложные элементы, которые не могут быть отображены в командной строке (картинки, формы и т.д.), показаны не будут.

Читайте также:  How to get date linux

Связанные статьи:

Рекомендуемые статьи:

12 Комментарии

А в винде команда конвертации недоступна? я могу открыть командой файл, но конвертироваться он не желает.
Пробовал разные варианты. С конкретным фалом, со всеми файлами в папке, конвертацию в разные фрматы, даже запуск в самом ридере swriter.exe с параметрами. В итоге все равно открывается, но не конвертится. Винда не может в последовательность команд ? Секретного варианта запуска и исполнения макроса, как в ворде, нету?

Там в одном примере даже зачем-то PS приплели.

В общем, проблема решилась с помощью Cygwin:

'C:/Program Files/LibreOffice 5/program/soffice.bin' --headless --convert-to pdf:writer_pdf_Export --outdir 'C:\tmp' 'C:\1.docx' convert C:\1.docx -> C:\tmp\1.pdf using filter : writer_pdf_Export

Т.е. в Cygwin я запускал файл soffice.bin. У Cygwin сразу два огромных плюса:

  • он выводит ошибки (это помогло мне узнать, что LibreOffice не может прочитать исходный файл)
  • можно использовать подстановочные символы (в командной строке Windows никакие бы звёздочки мы не смогли использовать, пришлось бы писать простой bat скрипт для автоматизации).
Batch convert files. If --outdir is not specified, then current working directory is used as output_dir.

обязательно нужно указывать оба параметра, ибо папка выхода сама не прописывается. Да, то что cmd ошибки не выводит это… раздражает Но в принципе

"C:\Program Files\LibreOffice 5\program\soffice.exe" --headless --convert-to pdf:writer_pdf_Export --outdir "C:\tmp" "C:\tmp\1.docx"

так запускается и отрабатывает даже в обычной cmd. PS Реадктор огонь, но… как вставлять в стиле кода?)

В стиле кода только для админа, причём только из админки при редактировании комментария – здесь даже я не могу вставить Это связано с фильтрацией данных (тегов).

"C:\Program Files\LibreOffice 5\program\soffice.exe" --headless --convert-to docx --outdir C:\Clip\Anton C:\Clip\Anton\Обзор ВП сентябрь 2019.doc
"C:\Program Files\LibreOffice 5\program\soffice.exe" --headless --convert-to docx --outdir "C:\Clip\Anton\Обзор ВП сентябрь 2019.doc"

Подскажите комманду для извлечения изображений из PDF-файла. То есть для каждой страницы PDF файла на выходе получается 1 картинка (jpg,png).

Добрый день! Не работает пакетная обработка, не пойму почему. soffice —headless —convert-to docx —outdir d:\doc\d2 d:\doc\d1\*.doc Error: source file could not be loaded а один файл работает soffice —headless —convert-to docx —outdir d:\doc\d2 d:\doc\d1\1.doc

Читайте также:  Linux файловая система оперативной памяти

Windows 10, LibreOffice 6.4, надо PDF во что-либо другое — не работает.
Уже и полные пути прописывал, и разные форматы пробовал — команда просто молча уходит в никуда.
Никаких ошибок, ни на что не ругается, просто пустота.
Пару раз появился пустой HTML-файл, и тот через минуту после команды.

Возможно, конвертировать можно только родные форматы. Что касается PDF, то такие файлы Writer даже не умеет открывать. Из пакета LibreOffice такие файлы умеет открывать только Draw, но эта программа может сохранить только в свой родной формат. В общем, вы выбрали неверный инструмент. FineReader умеет конвертировать PDF во что угодно. Причём PDF бывают двух видов — с текстовым слоем и без. Если текстовый слой есть, то его можно сохранить из любой программы для просмотра PDF. Если текстового слоя нет, то кроме OCR (программы для распознавания текста) никто его сохранить в текст не сможет. Максимум что можно сделать с таким файлом — это разбить на отдельные изображения. Возможно, FineReader поддерживает работу в командной строке, если вам нужно именно это. А так там очень удобно перетаскивать PDF прямо в программу и она его распознает и сохранит.

Источник

How to convert pdf to docx in libreoffice 6.4?

I have libreoffice 6.4 installed in my ubuntu 18.04 container. The goals is to convert a pdf file to docx. I have already tried these commands :

libreoffice --headless --convert-to docx:"Microsoft Word 2007/2010/2013 XML" /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to docx:"Microsoft Word 2007-2013 XML" /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to docx:"MS Word 2007 XML" /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to docx:writer_MS_Word_97 /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to "docx:writer_MS_Word_2007" /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to docx:writer_OOXML /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to doc /pdf/pdf.pdf --outdir /pdf libreoffice --headless --convert-to "docx:writer_MS_Word_2007" --outdir /pdf pdf.pdf 
convert /pdf/pdf.pdf -> /pdf/pdf.docx using filter : writer_MS_Word_2007 Overwriting: /pdf/pdf.docx Error: Please verify input parameters. (SfxBaseModel::impl_store failed: 0x81a(Error Area:Io Class:Parameter Code:26)) 
libreoffice --infilter="writer_pdf_import" --convert-to docx --outdir /pdf /pdf/pdf.pdf 
convert /pdf/pdf.pdf -> /pdf/pdf.docx using filter : Office Open XML Text Overwriting: /pdf/pdf.docx 

I can see it needs the —infilter— parameter, since the input file is a pdf. But, it’s using Office Open XML Text filter, I need to switch it to Microsoft Word 2007-2013 XML , how can I do that? I already tried these and not working :

libreoffice --infilter="writer_pdf_import" --convert-to docx:"Microsoft Word 2007-2013 XML" --outdir /pdf /pdf/pdf.pdf libreoffice --infilter="writer_pdf_import" --convert-to "docx:Microsoft Word 2007-2013 XML" --outdir /pdf /pdf/pdf.pdf libreoffice --infilter="writer_pdf_import" --convert-to "docx:writer_MS_Word_2007" --outdir /pdf /pdf/pdf.pdf libreoffice --infilter="writer_pdf_import" --convert-to docx:"writer_MS_Word_2007" --outdir /pdf /pdf/pdf.pdf libreoffice --infilter="writer_pdf_import" --convert-to docx:writer_MS_Word_2007 --outdir /pdf /pdf/pdf.pdf 
convert /pdf/pdf.pdf -> /pdf/pdf.docx using filter : writer_MS_Word_2007 Overwriting: /pdf/pdf.docx Error: Please verify input parameters. (SfxBaseModel::impl_store failed: 0x81a(Error Area:Io Class:Parameter Code:26)) 

Источник

How to Import PDF into LibreOffice?

PDF is one of the most commonly used formats in our daily life. In some occasions, we need to edit PDF. Of course, we can use Adobe Acrobat or a professional PDF editor, both of which are too expensive. So we may tend to use a free tool, such as LibreOffice, which is an excellent open source program for editing PDF files.

Читайте также:  Linux mint дата выхода последней версии

import pdf to libreoffice

What is LibreOffice?

LibreOffice is very similar to Microsoft Office. It consists of Text Document, Spreadsheet, Presentation, Drawing, Database, Formula, etc. The most attractive point is that it is totally free and compatible with multiple platforms like Windows XP, Windows 7, Windows Vista, Mac OS X (Mountain Lion included). With LibreOffice, we can edit DOC/RTF/PDF documents, modify spreadsheets, make presentations, and so on. To know more details, please go to see LibreOffice official site.

So how to import PDF to LibreOffice easily? In this article below, I will show you the details.

Edit PDF with LibreOffice Draw

LibreOffice Draw is a part of LibreOffice. Its functions are similar to CorelDraw, Photoshop, etc. And it also allows us to edit a PDF document as if it were an image file. To accomplish this, you can follow the steps below:

1) Launch LibreOffice suite. And choose Drawing.

2) Go to File -> Open. In the pop-up dialogue box, navigate to the PDF file and click Ok to import PDF into LibreOffice Draw.

3) Now you can edit text, images and layout of this PDF document just like an image file. Click, drag or double-click a line of text to edit. You can only edit a single line of text at a time. And typical image editing tools will apply.

edit pdf with libreoffice drawing

4) After editing, export the document as a PDF. To do so, click the PDF icon in the toolbar. Then enter a name, and click Save. Or you can click File -> Export as PDF from the menu.

Import PDF to LibreOffice Writer

LibreOffice Writer is a word processor similar to Microsoft Word program. It is good at modifying, editing, writing words. The supported input formats of LibreOffice are ODT(its default format), MS Word’s DOC, DOCX, RTF and XHTML. PDF can’t be opened directly with LibreOffice Writer. For importing PDF into LibreOffice Writer, users need to convert PDF to LibreOffice Writer supported formats. Here, I will introduce you how to convert Adobe PDF into Word DOCX format with PDF to Word Converter and then import to LibreOffice Writer.

Part1: Convert PDF to LibreOffice Format

Firstly, you need to free download, install and launch PDF to Word converter to your computer.

Then click Add File to add one or more PDF documents to the program. Set an output folder. Once finish all necessary settings, hit the Start button at the lower-right corner to kick off the conversion. After conversion, all original elements will be preserved without any loss.

Part2: Import to LibreOffice Writer

Run LibreOffice Writer on computer. Click the File -> Open to browse your computer for the target file. Now you can edit PDF with LibreOffice.

open pdf with libreoffice

Please note, all above steps are consumed that your PDF are not password protected. For password encrypted PDF files, you need to use PDF Password cracker to crack them.

See Also:

Источник

Оцените статью
Adblock
detector