diff --git a/aula197/arquivos_novos/X5.png b/aula197/arquivos_novos/X5.png new file mode 100644 index 0000000..15abddd Binary files /dev/null and b/aula197/arquivos_novos/X5.png differ diff --git a/aula197/main.py b/aula197/main.py index 35511fd..ef7fbdd 100644 --- a/aula197/main.py +++ b/aula197/main.py @@ -1,4 +1,4 @@ -# # PyPDF2 para manipular arquivos PDF (Instalação) +# PyPDF2 para manipular arquivos PDF (PdfReader) # PyPDF2 é uma biblioteca de manipulação de arquivos PDF feita em Python puro, # gratuita e de código aberto. Ela é capaz de ler, manipular, escrever e unir # dados de arquivos PDF, assim como adicionar anotações, transformar páginas, @@ -7,3 +7,28 @@ # Link: https://pypdf2.readthedocs.io/en/3.0.0/ # Ative seu ambiente virtual # pip install pypdf2 +from pathlib import Path + +from PyPDF2 import PdfReader + +PASTA_RAIZ = Path(__file__).parent +PASTA_ORIGINAIS = PASTA_RAIZ / 'pdfs_originais' +PASTA_NOVA = PASTA_RAIZ / 'arquivos_novos' + +RELATORIO_BACEN = PASTA_ORIGINAIS / 'R20230210.pdf' + +PASTA_NOVA.mkdir(exist_ok=True) + +reader = PdfReader(RELATORIO_BACEN) + +# print(len(reader.pages)) +# for page in reader.pages: +# print(page) +# print() + +page0 = reader.pages[0] +imagem0 = page0.images[0] + +# print(page0.extract_text()) +# with open(PASTA_NOVA / imagem0.name, 'wb') as fp: +# fp.write(imagem0.data)