yakovmeister / pdf2image

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

Remove .page-number from the saved filename #192

Open batchor opened 1 year ago

batchor commented 1 year ago

Remove the .page-number from the resulting image filename and let user fully control the output filename via saveFilename.

mskec commented 1 year ago

Hi @batchfy-bot, removing the page number might work for 1-page PDFs. We can consider it, but that would be breaking change and would have to wait for the next major release.

How do you propose we name multi-page PDFs in .bulk conversion?

You can always convert to buffer and save file with fs.

const convert = fromPath("./test/data/pdf1.pdf")
const pagePng = await convert(2, { responseType: "buffer" })
await fs.writeFile('./page.png', pagePng.buffer)
batchor commented 1 year ago

@mskec I mean we can optionally let the user to fully control the resulting image filename. I understand that a page number is necessary for bulk mode.

In my case, I'm creating a snapshot (first page only) of a pdf file. In my particular case, I only need one single outcome: pdf-file-name-snapshot.jpg without the page number.

Anyway, I think the buffer to file is a good solution. Thank you!