libreofficedocker / unoserver-rest-api

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

convert to html #6

Open DivagoNM opened 2 months ago

DivagoNM commented 2 months ago

hi I try convert docx to html,it works great, but the images are stored in the unoserver folfer, how i can return this images?

socheatsok78 commented 2 months ago

By default the request will response the result out put of the file after conversion.

Example:

curl -s -v \
   --request POST \
   --url http://127.0.0.1:2004/request \
   --header 'Content-Type: multipart/form-data' \
   --form "file=@/path/to/your/file.xlsx" \
   --form 'convert-to=pdf' \
   --output 'file.pdf'
DivagoNM commented 2 months ago

yes, works perfect for me, i have a problem whe convert a doxc to html, i can use inline images, but if i use a standet html output, can donwnload images?

DivagoNM commented 1 month ago

--form 'convert-to=html:HTML:EmbedImages' \ error 500 ?

miikatoi commented 1 month ago

Hi @DivagoNM,

Looks like currently unoserver does not support this. According to https://github.com/unoconv/unoserver/issues/110, XHTML filter may handle it, but I couldnt make it work in this API without other errors.

As a temporary workaround I just made additional API container that handles inserting the images into the html before returning the document. You can refer to https://github.com/miikatoi/unoserver-rest-api-wrapper on how to do it.

Hope it solves your problem as well.

miikatoi commented 1 month ago

Updating my findings here.

XHTML filter works correctly in some cases, but raises an error in others. For example:

Here is the request I used:

curl -s -v \
   --request POST \
   --url http://127.0.0.1:2004/request \
   --header 'Content-Type: multipart/form-data' \
   --form 'file=@/path/to/your/file' \
   --form 'convert-to=html' \
   --form 'opts[]=--filter=XHTML Writer File' \
   --output 'output.html'
DivagoNM commented 1 month ago

Thanks!!