简体   繁体   English

与--stdin的unoconv无法正常工作

[英]unoconv with --stdin not working

I am using unoconv to convert docx to pdf . 我正在使用unoconvdocx转换为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: 但是,一旦我使用--stdin它将不再起作用:

$ 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 这是文件: 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. 我认为问题在于--stdin选项无法执行人们可能认为的操作。

In the error message, the variable name in line 1185 looks suspicious: 在错误消息中,第1185行中的变量名称看起来可疑:

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. 实际上,检查源代码后 ,似乎从STDIN读取的文本被解释为文件 ,而不是文件内容。

However, the documentation ( man unoconv ) is misleading: 但是,文档( man unoconv )具有误导性:

--stdin --stdin
Read input file from stdin (filenames are ignored if provided) 从stdin读取输入文件(如果提供,则忽略文件名)

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). 我建议您提交有关此问题的错误报告 (也许首先检查是否已经存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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