Reputation: 208
I want to generate an image preview of a word docx file similar to Google Drive (see image). Essentially, the client uploads a docx that is sent to the backend. The backend takes a snapshot of the first page of the file and sends that image back to the client.
Is there a way to take a snapshot of a word file in the backend--or even in the client-side? Any tools to do this?
Upvotes: 5
Views: 5303
Reputation: 561
There does seem to be a library for you to start with: https://www.npmjs.com/package/docx-preview
The preview works for simple documents. For server-side usage, one would still need to render the canvas output to a picture and send that to the requesting client.
EDIT: For server-side usage only, it seems versatile solutions are already; see https://www.npmjs.com/package/filepreview-es6 or https://www.npmjs.com/package/filepreview respectively. (note that for more common media types like pictures/videos, there may be better preview generators available).
Upvotes: 1
Reputation: 27
you can use node canvas https://www.npmjs.com/package/canvas or you can use IMG4Me - Text to Image Service API to generate an image from text https://rapidapi.com/seikan/api/img4me-text-to-image-service
Upvotes: 1