简体   繁体   中英

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM