Created
October 21, 2022 08:16
-
-
Save ahmadmustafaanis/9b672cb9699fd109d19139675a284770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fpdf import FPDF | |
for hero_num in range(len(self.all_interviews_results)): | |
pdf = FPDF() # Creates a new PDF File for each hero | |
pdf.add_page() | |
pdf.set_font("Arial", "B", 16) # sets font for title | |
pdf.cell(0,0,txt=f"Interview of {list(interviews_details.values())[hero_num]}", ln=1, align="C") # Adds the Title to the PDF, title is the name of the hero. | |
pdf.ln() | |
pdf.set_font("Arial", size=12) # Font for other text | |
for line in range(len(self.all_interviews_results[hero_num]["segments"])): | |
pdf.cell(200, 10,txt =self.all_interviews_results[hero_num]["segments"][line]["text"], ln=1,) # Adds each seperate line to PDF | |
pdf.output(f"{list(interviews_details.values())[hero_num]}.pdf") # Store the PDF with the name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment