File size: 577 Bytes
dcfd77f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pypdfium2 as pdfium
import os
pdf = pdfium.PdfDocument("fin_irjmets1648020477.pdf")
n_pages = len(pdf)

for page_number in range(n_pages):
    page = pdf.get_page(page_number)
    pil_image = page.render(scale = 300/72).to_pil()
    """
    pil_image = page.render(
        scale=1,
        rotation=0,
        crop=(0, 0, 0, 0),
        colour=(255, 255, 255, 255),
        annotations=True,
        greyscale=False
    ).to_pil() """
    image_folder = "pdf_images"
    save_path = os.path.join(image_folder, f"image_{page_number+1}.png")
    pil_image.save(save_path)