Python 3 Tkinter FPDF Library Script to Convert or Export Raw Text to PDF Document GUI Desktop App Full Project For Beginners

Python 3 Tkinter FPDF Library Script to Convert or Export Raw Text to PDF Document GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be export raw text to pdf documentusing fpdf library in tkinter using python. All the full source code of the application is given below.

 

 

Get Started

 

 

First of all install the below library using the pip command as shown below

 

pip install fpdf

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

from tkinter import *
from tkinter.filedialog import *
from tkinter.scrolledtext import ScrolledText
from fpdf import FPDF


def export():
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", "", 16)
    pdf.cell(40, 10, textbox.get("1.0", END).strip())
    pdf.output(asksaveasfilename(filetypes=[("PDF file", "*.pdf")]), "F")

root = Tk()
root.title("Text2PDF")
textbox = ScrolledText(root)
textbox.pack(fill=BOTH, expand=YES)
Button(root, text="Export to PDF", command=export).pack(fill=X)
root.mainloop()

 

 

Now run the python script by typing the below command as shown below

See also  Python 3 Tkinter Address or Phone Book Contact Management System Using SQLite Database GUI Desktop Full Project For Beginners

 

python app.py

 

 

 

Leave a Reply