예제 #1
0
import pyPDF2 
# Cargar el pdf original y el que contiene la marca de agua 
pdf_original = open('original.pdf', 'rb')
pdfwatermark = pyPDF2.pdfFileReader(open('marca_agua.pdf', 'rb'))
pdfReader = pyPDF2.pdfFileReader(pdf_original)

# Fusionar la primera pagina de cada documento 
FirstPage = pdfReader.getPage(0)
FirstPage.mergePage(pdfwatermark.getPage(0))

# guardar la pagina fusionada en un objeto pdfFileWriter
pdfWriter = pyPDF2.pdfFileWriter()
pdfWriter.addPage(FirstPage)

# Agreegar el contenido restante del PDF al original 
for pageNum in range(1, pdfReader.numPages):
	pageObj = pdfReader.getpage(pageNum)
	pdfWriter.addPage(pageObj)

# Guardar y cerrar archivos 
resultPdfFile = open('watermarkedPDF.pdf', 'wb')
pdfWriter.write(resultPdfFile)
pdf_original.close()
resultPdfFile.close()
예제 #2
0
import pyttsx3
import pyPDF2
book = open('Test12.pdf','rb') //Get value 
pdfReader = pyPDF2.pdfFileReader(book)
pages = pdfReader.numPages
print(pages)
speaker = pyttsx3.int()
for num in pages:
    page = pdfReader.getPage(7, pages)
    text = page.extractText()
    speaker.say(text) //output
    speaker.runAndwait()
예제 #3
0
import pyPDF2
pdf_file = open('3.Pengenalan Java dan Netbeans.pdf')  #pdf name

read_pdf = pyPDF2.pdfFileReader(pdf_file)

print(read_pdf.numPages)
pageObj = read_pdf.getpage(0)

print(pageObj.extractText())
pdf_file.close()