Description: Convert PDF to Image will throw whenever one of the condition is reached
        Parameters:
            pdf_file -> Bytes representing the PDF file
            dpi -> Image quality in DPI
            poppler_path -> Path to look for poppler binaries
            output_folder -> Write the resulting images to a folder (instead of directly in memory)
            first_page -> First page to process
            last_page -> Last page to process before stopping
            fmt -> Output image format
            thread_count -> How many threads we are allowed to spawn for processing
            userpw -> PDF's password
            use_cropbox -> Use cropbox instead of mediabox
            strict -> When a Syntax Error is thrown, it will be raised as an Exception
            transparent -> Output with a transparent background instead of a white one.
            output_file -> What is the output filename
            poppler_path -> Path to look for poppler binaries

def convert_from_bytes(pdf_file, dpi=200, output_folder=None, first_page=None, last_page=None,
                       fmt='ppm', thread_count=1, userpw=None, use_cropbox=False, strict=False, transparent=False,
                       output_file=str(uuid.uuid4()), poppler_path=None):
    """
        Description: Convert PDF to Image will throw whenever one of the condition is reached
        Parameters:
            pdf_file -> Bytes representing the PDF file
            dpi -> Image quality in DPI
            poppler_path -> Path to look for poppler binaries
            output_folder -> Write the resulting images to a folder (instead of directly in memory)
            first_page -> First page to process
            last_page -> Last page to process before stopping
            fmt -> Output image format
            thread_count -> How many threads we are allowed to spawn for processing
            userpw -> PDF's password
            use_cropbox -> Use cropbox instead of mediabox
            strict -> When a Syntax Error is thrown, it will be raised as an Exception
            transparent -> Output with a transparent background instead of a white one.
            output_file -> What is the output filename
            poppler_path -> Path to look for poppler binaries
    """

    fh, temp_filename = tempfile.mkstemp()
    try:
        with open(temp_filename, 'wb') as f:
            f.write(pdf_file)
            f.flush()
            return convert_from_path(f.name, dpi=dpi, output_folder=output_folder,
                                     first_page=first_page, last_page=last_page, fmt=fmt, thread_count=thread_count,
                                     userpw=userpw, use_cropbox=use_cropbox, strict=strict, transparent=transparent,
                                     output_file=output_file, poppler_path=poppler_path)
    finally:
        os.close(fh)
        os.remove(temp_filename)