yumauri / gotenberg-js-client

A simple JS/TS client for interacting with a Gotenberg API
MIT License
111 stars 9 forks source link

Can I convert docx from Buffer? #15

Closed shaharsol closed 4 years ago

shaharsol commented 4 years ago

In the Readme it shows how to convert HTML by passing a string. Let's say I have the docx in a Buffer, can I use it to convert to PDF, instead of having to save it to the filesystem only to be able to post it to gotenberg?

yumauri commented 4 years ago

Yes, sure! Source can be Buffer:

const toPDF = pipe(
  gotenberg('http://localhost:3000'),
  convert,
  office,
  please
)

// --- 8< ---

const buffer = ...
const pdf = await toPDF({ 'document.docx': buffer })
yumauri commented 4 years ago

I've added few lines to README file, with example of streaming downloaded file to Gotenberg, without saving it to the disk.