libreofficedocker / unoserver-rest-api

The simple REST API for unoserver
Apache License 2.0
21 stars 4 forks source link

Error when passing --filter-options #7

Open willmakenoise opened 1 month ago

willmakenoise commented 1 month ago

Hi,

I'm trying to pass filter-options to the rest api, but I'm getting an error: "unoconvert error: exit status 2"

I've tried several different options with the same result.

Here is an example request:

curl --location 'localhost:2004/request' \
--form 'file=@"report.xlsx"' \
--form 'convert-to="pdf"' \
--form 'output="test.pdf"' \
--form 'opts[]="--filter=writer_pdf_Export"' \
--form 'opts[]="--filter-options Quality=50"'

Any ideas?

miikatoi commented 1 month ago

Hi @willmakenoise ,

I was facing the same issue, but eventually discovered that breaking down '--form 'opts[]=--filter-options foo=bar' into two separate lines:

The commands worked fine inside the container, but from requests they were not being formatted correctly into the unoconvert command. Maybe it has something to do with the space character.

For reference, here is a command that succesfully returned pages 1 and 2 in my case.

curl -s -v \
   --request POST \
   --url http://127.0.0.1:2004/request \
   --header 'Content-Type: multipart/form-data' \
   --form "file=@demo.docx" \
   --form 'convert-to=pdf' \
   --form 'opts[]=--filter-options' \
   --form 'opts[]=PageRange=1-2' \
   --output 'file.pdf'

Hope it solves your issue too!

willmakenoise commented 1 month ago

Thank you @miikatoi!

That worked beautifully 😀