

Image_of_pdf = np.concatenate(tuple(convert_from_path('source2.pdf')), axis=0) To resize the image for the screen you'll use the following code that uses cv2's built-in resize function: import cv2 This will probably create a window on the screen that is too big. This next bit of code will show the image on the screen: cv2.imshow("Image of PDF", image_of_pdf) If you want them side by side you could change the axis integer to 1 signifying you want to concatenate the images along the y-axis. We convert the list into a tuple for the numpy concatenate function to stack the images on top of each other. The pdf2image library's convert_from_path() function returns a list containing each pdf page in the PIL image format.

Image_of_pdf = np.concatenate(tuple(convert_from_path('/path/to/pdf/source.pdf')), axis=0) The next bit of code can convert the pdf into one big image readable by cv2: import cv2

Readable_images_of_pdf.append(np.array(PIL_Image)) # Add items to list Readable_images_of_pdf = # Create a list for thr for loop to put the images into Images_of_pdf = convert_from_path('source2.pdf') # Convert PDF to List of PIL Images Note: The following code requires numpy pip install numpy. The next sample of code will convert the PIL Image into something readable by cv2: You can then convert the file into one or multiple images readable by cv2. Install with this command: pip install pdf2image. I need a solution in which I can convert PDF to image and use it directly instead of saving on disk and read them again from there. It should first convert PDF into image format readable by opencv for same processing as above. I want to give this program scanned PDF as input instead of image above. Now, at the end I am getting a PDF with rectangle on matched date pattern. I am using following code to draw rectangle on an image text for matching date pattern and its working fine.
