How to Convert XML and JSON Files to PDF in Python Using pdfitdown Library in Terminal
406 views
Jun 3, 2025
Get the full source code of application here:
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
So in this video I will show you uh how
0:05
to convert your XML and uh
0:10
uh XML and JSON file into
0:13
PDF So
0:16
uh inside Python So for this we have
0:19
actually a dependency that you need to
0:21
install Uh the dependency name is PDF it
0:26
down So this is actually the command
0:29
here Simply install this by executing
0:32
this pip command I've already installed
0:34
it And uh after installing it uh you
0:38
just need to create a simple users file
0:41
So you can see both the JSON and XML
0:44
file are there in my working directory
0:48
And inside this user JSON file you see
0:51
an array of object Each object has some
0:56
properties and same we have this XML
0:59
file as well So now we we will look at
1:01
how to convert both these files to PDF
1:05
So just create a simple app py file So
1:09
the result will look something like this
1:11
You can see this is your JSON file
1:13
successfully converted to PDF And same
1:16
goes with this as well This is your XML
1:19
data converted to PDF So now let me show
1:22
you how to actually write
1:27
this So just create a simple app py file
1:31
and
1:38
uh after that first of all you need to
1:41
import the package So we simply say from
1:45
PDF it down it contains this function
1:49
PDF
1:50
conversion and from this you need to
1:53
import this PDF
1:55
conversion Sorry not PDF conversion
1:58
There is a method here which you need to
2:00
import which is converter After that uh
2:03
you just need to initialize this
2:06
converter like this After initializing
2:10
this converter it has some a series of
2:12
methods So one such method is this
2:15
convert method It takes two arguments
2:18
First of all your file
2:21
path So here you will
2:23
specify your JSON file and then it takes
2:26
the second argument which is your output
2:28
path So this will be the PDF file which
2:32
get created Same we will do this for XML
2:36
as well
2:39
So here you will replace your XML file
2:43
and
2:48
then so as soon as you execute this
2:50
application on the left hand side you
2:52
will see these two files will get
2:55
created the JSON and XML file will get
2:59
converted to
3:02
PDF So you will see both the files have
3:04
been created So in this easy way you can
3:07
use this Python package to carry out the
3:10
conversion from JSON to PDF and XML to
3:13
PDF So you'll see all the JSON data has
3:16
been successfully inserted to the PDF
3:18
document and same is your XML data as
3:21
well So this was the XML file and this
3:24
is your PDF file So uh you can use this
3:27
package very important package inside
3:30
Python Uh thank you very much for
3:32
watching this video and also check out
3:34
my website freemediattools.com
3:37
uh which contains thousands of tools
#Programming
#Scripting Languages