So in this particular lecture, let's go ahead and let's learn how we could generate a PDF like this.
So in order to generate a PDF like that, we need to have a header.
We could also add a footer if we want to.
But first of all, let's go ahead and let's learn how to add a header over here to our PDF and then
display all of this data here.
So we are going to keep this document open for reference.
So let's go ahead and let's get started.
So once we have all of this information here, like name, email, phone number, we simply have to
pass this information to a function so that that function can actually create a PDF for us.
So instead of using a function here, we actually will go ahead and create a class which inherits from
the PDF class.
And the reason why we need to inherit from the PDF class is because what we need to do is we also need
to override the header method as well because we actually want to create a header.
And the reason why we need a header is because if you take a look at the document here, we want to
add a QR code at the top using the header.
So now the question is how exactly are you going to create that?
So in order to create that, first of all, let's create a class.
So let's go at the very top right up over here.
And I would create a class over here and let's name this class as PDF CV, because this particular program
is going to generate CV and this needs to inherit from the PDF class which we have just imported.
And now the reason why we actually inherit from this one is because we need to use the methods which
are present in there.
So first of all I would say def header.
So this header is actually going to be used to add the QR code.
So here in this header, what we wish to do is we wish to take the QR code which is generated.
So what happens is when you execute this code, it actually creates a QR code in the form of an image,
which is my website dot PNG.
And that particular image is going to be available over here.
Now once that image is available, you simply have to add that particular image to the PDF document
which you have.
So over here I could say self dot, that's going to be image.
And the name of the image is nothing, but it's actually my website dot PNG.
And then I would give a comma and add the rest of the parameters such as the X position, the Y position.
So I would say the x coordinate is ten, y coordinate is eight.
Let's set the width to something like 33 and you could also set the title for this one.
So I would say title.
Is going to be equal to something like Port folio site.
All right.
So this actually adds the logo for us.
After this, you could also add a footer if you want to.
So I would say dev footer.
And right now, for the moment, I'm not going to add any code in there.
Therefore, I would add a pass here.
All right.
So after this, once the header and footer are created, now we need to create the rest of the body
depending upon the information which we have.
So first of all, we have to get the name here.
So in order to create that particular part of the document, I'll create a different function here or
a different method inside this class.
So let's call this particular method as generate underscore CV method, and we are going to call this
particular method over here when we have all the information collected.
So what we will do is we will actually create a class of that particular fpdf So let me give you a straight
away demo.
So instead of actually creating the class, first I'll show you how to pass this information, which
is all the name, email, phone number, work experience to the above created method.
So first of all, let's create an object of the class which is fpdf and remember that you have to create
it inside this generate CV function itself.
So make sure that you are indented over here.
So CV equals pdf CV.
So we have created the object of the above class.
And now if I want to access this generate CV method, what I simply have to do here is I simply have
to say CV dot generate CV So generate underscore CV And to this particular method I now have to pass
in all the data like name, email, phone number, address, so on and so forth.
So let's pass that over here.
So name, email, phone number, address, skills, work experience, education about me.
So once all of that information is added, now I need to make this particular method capable of actually
accepting all of those particular arguments.
So first of all, I'll make it accept self, then name email and make sure that the order over here
is accurate or else you're going to face an error.
So you need to use the same order there.
So I'll simply copy all the code from here and simply paste it up over here so as to keep things accurate.
And that's it.
So once we have this now, we could go ahead and start working on creating the page which we have.
So for now, I'll add a pass here.
So once we have this particular method, this particular method now has access to all the data which
is being collected over here.
So once it has access to that, we could go ahead and start creating our PDF page, just as we do in
a simple case where we use a class to create a PDF page.
So whenever you want to create a page here, you simply make use of the self, which is the current
instance, and then use the methods like add page, the cell method to add the different kinds of data
points, so on and so forth.
So let's learn how we could lay out the structure of this particular page for creating this PDF in the
next lecture inside this generate method.
So let's learn about that in the next one.