Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unoconv with --stdin not working

I am using unoconv to convert docx to pdf. All works great as long as I am passing the document via file name:

$ unoconv -f pdf --stdout test.docx

But as soon as I am using --stdin it doesn't work anymore:

$ unoconv -f pdf --stdin --stdout < test.docx

Traceback (most recent call last):
  File "/usr/bin/unoconv", line 1275, in <module>
    main()
  File "/usr/bin/unoconv", line 1185, in main
    inputfn = sys.stdin.read()
  File "/usr/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 41: invalid start byte

It's the same file. Why doesn't this work?

Here is the file: https://nofile.io/f/bKz1zWf745K/test.docx

like image 266
Werzi2001 Avatar asked Mar 06 '23 19:03

Werzi2001


1 Answers

I think the problem is that the --stdin option doesn't do what one probably thinks it does.

In the error message, the variable name in line 1185 looks suspicious:

inputfn = sys.stdin.read()

And indeed, checking the source code, it seems that the text read from STDIN is interpreted as the file name, not the file content.

However, the documentation (man unoconv) is misleading:

--stdin
Read input file from stdin (filenames are ignored if provided)

This really doesn't sound like interpreting the input as file name.

I suggest that you file a bug report about this (maybe first check if there is one already).

like image 65
lenz Avatar answered Mar 20 '23 03:03

lenz