yakovmeister / pdf2image

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

YOU DONT NEED THIS LIBRARY #163

Closed sladg closed 1 year ago

sladg commented 1 year ago

Considering this library is not maintained anymore (last commit 3 years ago, no response from author), here is a solution using ghostscript-node.

import { readFileSync } from 'fs'
import gs from 'ghostscript-node'

export const convertPdfToPng = async (filePath: string) => {
  const pdfBuffer = readFileSync(filePath)
  const firstPage = 1
  const lastPage = 22
  const dpi = 600

  return await gs.renderPDFPagesToPNG(pdfBuffer, firstPage, lastPage, dpi)
}
mskec commented 1 year ago

Hi @sladg

We will try to keep it maintained. Please feel free to submit an issue if you have some bug to report.