I am working on a simple application which will help me to convert all my pdf files which have text in English to French text as pdf. I have worked on a simple proof of concept which helps me to iterate over the given file and convert all text into French. Now I am stuck on saving the converted french text into a pdf with a similar structure of the original English version.
import PyPDF2
from googletrans import Translator
translator = Translator()
read_pdf = PyPDF2.PdfFileReader(open('any_english.pdf', 'rb'))
write_pdf = PyPDF2.PdfFileWriter()
number_of_pages = read_pdf.getNumPages()
for i in range(number_of_pages):
page = read_pdf.getPage(i)
page_content = page.extractText()
print translator.translate(page_content, dest='fr').text
// Save the converted version text in french into a pdf conserving structure as original pdf
**Note
All contents in the pdf are text format not image.