I have to call a api(from react axios) and the api needs to convert the pdf to image files and save it in local and get the saved local path… Below is a python function which converts pdf to png format but how to convert it to an endpoint?
from pdf2image import convert_from_path
from pdf2image.exceptions import ( PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError)
def PDFtoImage(link):
images = convert_from_path(link,poppler_path=r’C:\Program Files\poppler-0.68.0\bin’)
for i, image in enumerate(images):
fname = “image” + str(i) + “.png”
image.save(fname,“PNG”)PDFtoImage(‘onepage.pdf’)