yakovmeister / pdf2image

A utility for converting pdf to image and base64 format.
MIT License
434 stars 141 forks source link

Wont work in linux #205

Closed YashjeetAlaan closed 4 months ago

YashjeetAlaan commented 4 months ago

I am doing below things const convert = fromBuffer(pdfBuffer, options); const result = await convert(1, { responseType: 'buffer' }); result is {"buffer":[]}

My docker file FROM node:20.9.0-alpine3.18

RUN apk update \ && apk add --no-cache make g++ python3 ghostscript graphicsmagick ghostscript-fonts WORKDIR /api COPY functions /api RUN npm install -g npm@10.8.0 RUN npm ci COPY .sh /bin/ RUN chmod 755 /bin/.sh CMD /bin/worker_start.sh

It works fine in mac But when we deployed code to linux container it simple wont work

mskec commented 4 months ago

Hi @YashjeetAlaan,

I just tried running it in docker based on your Dockerfile and I got the expected output.

❯ docker run pdf2pic-docker
{
  buffer: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 00 00 00 05 2d 08 00 00 00 00 47 33 69 03 00 00 00 09 70 48 59 73 00 00 00 48 00 00 00 48 00 ... 308239 more bytes>,
  size: '1024x512',
  page: 1
}

Please check the PR #206 for the exact Dockerfile I used.

cesargdm commented 3 months ago

I tried the above but didn't work. I ended up using inkscape with https://github.com/papandreou/node-inkscape at v2 (not v3), in case that it works for someone, that library also supports streams.