Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
477 B
4
Indexable
Never
import pypdfium2 as pdfium

pdf = pdfium.PdfDocument("salute_example_1.pdf")
version = pdf.get_version()  # get the PDF standard version
n_pages = len(pdf)  # get the number of pages in the document
n_pages

page_indices = [i for i in range(n_pages)]  # all pages
renderer = pdf.render_to(
    pdfium.BitmapConv.pil_image,
    page_indices = page_indices,
    scale = 300/72,  # 300dpi resolution
)
for i, image in zip(page_indices, renderer):
    image.save(f"salute_{i}.jpg")