Converting doc to pdf

3

I try to convert a doc file to a pdf file with the linux bash.
I tried different ways like jodconverter, ghostscript, postscript and so on, but all didn't work as espected.
Additionally I can say that I have only the bash.

Is there any way, which you can advice me?

CSchulz

Posted 2011-09-19T15:40:33.357

Reputation: 229

Thanks, but nothing works for me. :) – CSchulz – 2011-09-19T16:33:18.640

Answers

2

Have you tried unoconv?

I did, and it seems to work. This is what I did (after lots of googling :):

  1. I installed unoconv (I had Libre Office installed)
  2. Booted to console (no X server running)
  3. Started soffice in headless mode with this command:

    /usr/lib/libreoffice/program/soffice.bin -headless -nofirststartwizard -accept="socket,host=localhost,port=8100;urp;StarOffice.Service" &

After that, simple unoconv document.doc converted document.doc to document.pdf (pdf is default output format).

Goran Jurković

Posted 2011-09-19T15:40:33.357

Reputation: 306

Thanks for the answer. I get following error "unoconv: UnoException during conversion: URL seems to be an unsupported one. The provided document cannot be converted to the desired format.". I searched for it at google, but I can't find any solution. – CSchulz – 2011-10-05T10:12:38.883

libreoffice -headless -convert-to pdf document.doc How about this? – Goran Jurković – 2011-10-06T12:38:12.820

The argument headless is deprecated. --headless is the new argument. :) I got following error: stat: cannot read file system information for `test.doc': Input/output error – CSchulz – 2011-10-12T08:28:23.780

Hm, it could be some kind of a file system problem...

I assume test.doc is in your current directory, try stat test.doc
It could be that you are not able to access that file at all. – Goran Jurković – 2011-10-13T14:31:41.547

Now it seems that the command work, but I can't find the output or an argument for it. – CSchulz – 2011-10-14T07:41:20.017

If it doesn't create output file, then it doesn't work :)

It might be a simple ownership/permission problem, did you check that?

Maybe you should first try something simpler, like creating simple text file, and if you are sure you can access it and read it, try converting it to pdf.

For example, something like this:

echo "This is a test" > test.txt and after that

`libreoffice --headless -convert-to pdf test.txt`    

and see what happens. It should create file test.pdf . – Goran Jurković – 2011-10-14T12:35:58.123

Nothing happened, there is no output file. I don't know what is wrong. – CSchulz – 2011-10-15T14:02:24.433

It's hard to say, but maybe you misunderstood something here:

You shouldn't run unoconv and soffice.bin prior to using "libreoffice --headless ..." The behaviour you described (no output at all) in my experience happened when soffice.bin was already running. So, ps -e | grep soffice shouldn't give any output.

Also, check that you have sufficient permissions, but I guess you already did that. – Goran Jurković – 2011-10-15T17:53:14.667

Oh I didn't know that yet, I had tried again but with the same results. I am running that command in /tmp. – CSchulz – 2011-10-16T12:47:04.787

Well, if there is absolutely no output, and you are sure permissions are set up correctly, (you can access the file you are trying to convert and you have write permissions to /tmp) you can try running strace. Something like strace -f -o libre.log libreoffice --headless -convert-to pdf test.doc After that you should have libre.log file with log of what was happening. – Goran Jurković – 2011-10-17T11:37:31.700

Here is my stacktrace, I hope you can help me with these informations: http://pastebin.com/pKUA4F44

– CSchulz – 2011-10-17T13:25:14.970

Well, I was hoping to find something obvious, but it didn't happen. But, there are some log.txt files mentioned in strace, maybe they hold something useful. And take a look here: link and link. Regarding unoconv, I guess running libreoffice (it's a simple shell script which starts soffice) is better option than unoconv, because unoconv still relies on open/libre office built-in converting features, and another layer of complexity is probably even more error-prone.

– Goran Jurković – 2011-10-18T18:15:18.060

9

lowriter --convert-to pdf *.doc

lowriter is the 'writer' program from LibreOffice (maybe your distro's LibreOffice package differs - check this!).

uzsolt

Posted 2011-09-19T15:40:33.357

Reputation: 1 017

1Thanks but I haven't a running X-Server. – CSchulz – 2011-09-20T11:32:50.277

3

Get into the folder that has your LibreOffice and run this in terminal.

./soffice --headless --convert-to pdf --outdir destination_path source_path/*.doc 

Or using Unoconv

unoconv -f pdf File.doc

Preethi Kumar

Posted 2011-09-19T15:40:33.357

Reputation: 145