How To Develop A CV Builder Using Java

by | Feb 27, 2023 | Basic Coding, Coding, Java

Home » Coding » How To Develop A CV Builder Using Java

Introduction of the Project

In this Java project tutorial, we will learn how to develop a CV builder using Java that creates a Resume pdf for the information given by the user. In today’s job market, having a strong and well-crafted resume can make all the difference in securing your dream job. However, creating a personalized and professional CV can be a daunting task, especially if you’re starting from scratch. That’s where a CV builder comes in handy.

With the help of Java, you can create your own CV builder that can generate a customized resume with ease. In this project tutorial, we’ll guide you through the process of developing your own CV builder using Java, so you can stand out from the competition and land your dream job.

We will be using swing to implement the GUI of our CV builder and provide the functionality to create & edit a pdf file with data captured.

Objectives

1. To teach the basics of Java programming language and how to utilize it to create a functional CV builder.

2. To implement the itextpdf package to get access to PdfWriter & Document class which in turn creates a pdf file & makes it possible to edit it.

3. To guide learners on the importance of personalized and professional resumes in securing job opportunities.

4. To provide step-by-step instructions on how to develop a CV builder in Java, including the creation of a graphical user interface (GUI) and the implementation of data structures.

5. To show how to incorporate features such as auto-fill, spell-check, and export options into the CV builder to make it user-friendly and efficient.

6. To help learners gain practical experience in developing a real-world application in Java and apply the concepts learned to future programming projects.

Requirements

To develop a CV builder using Java, it is recommended that you have the following prerequisites:

1. Basic knowledge of Java programming language, including object-oriented programming concepts such as classes, objects, methods, and inheritance.

2. Familiarity with Java Development Kit (JDK) and Integrated Development Environment (IDE), such as IntelliJ IDEA or NetBeans.

3. Understanding of graphical user interface (GUI) design principles and experience with GUI toolkits, such as Swing or JavaFX. We have used Java’s Swing framework as it has several components that give developers the freedom and flexibility to create eye-catching interfaces for Windows-based applications. Also, the best thing about using Swing module to create components like tables, scrollbars and buttons is that the framework is platform independent & Apache iText is an open-source Java library that supports the development and conversion of PDF documents.

4. Knowledge of data structures, such as arrays and linked lists, and their implementation in Java.

5. Familiarity with file handling and input/output operations in Java.

6. Awareness of resume writing and formatting guidelines to ensure the CV builder generates a professional-looking resume.

Source Code

Main.java

package com.company;
public class Main {
public static void main(String[] args) {
new CV();
}
}

CV.java

package com.company;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
public class CV {
private JPanel cvPanel;
private JTextField name;
private JTextField address;
private JTextField contact;
private JTextField email;
private JTextField skills1;
private JTextField skills2;
private JTextField skills3;
private JTextField skills4;
private JComboBox work;
private JTextField college;
private JTextField qualiA;
private JButton SELECTIMAGEButton;
private JLabel img;
private JButton GENERATERESUMEButton;
private JTextField qualiB;
private JTextField location;
JFrame frame = new JFrame();
public CV() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(cvPanel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
SELECTIMAGEButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("*.IMAGE","jpg","png");
fileChooser.addChoosableFileFilter(filter);
int rs = fileChooser.showSaveDialog(null);
if(rs==JFileChooser.APPROVE_OPTION){
File selectedImage = fileChooser.getSelectedFile();
location.setText(selectedImage.getAbsolutePath());
img.setIcon(resize(location.getText()));
}
}
});
GENERATERESUMEButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(name.getText()==null||contact.getText()==null||address.getText()==null||email.getText()==null){
JOptionPane.showMessageDialog(null,"PLEASE ENTER ALL DETAILS TO GENERATE CV");
}else{
try {
String nameOfFile = "D:\\PDFYAHA\\my.pdf";
Document myDocument = new Document();
PdfWriter.getInstance(myDocument, new FileOutputStream(nameOfFile));
myDocument.open();
com.itextpdf.text.Image img = com.itextpdf.text.Image.getInstance(location.getText());
img.setAbsolutePosition(473f, 750f);
img.scaleAbsolute(80f,70f);
PdfPTable table = new PdfPTable(2);
myDocument.add(img);
myDocument.add(new Paragraph(name.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,32, com.itextpdf.text.Font.BOLD,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_BOLD,9,BaseColor.DARK_GRAY)));
myDocument.add(new Paragraph("",FontFactory.getFont(FontFactory.TIMES_BOLD,9, BaseColor.DARK_GRAY)));
myDocument.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
myDocument.add(new Paragraph("CONTACT DETAILS",FontFactory.getFont(FontFactory.TIMES_BOLD,9, com.itextpdf.text.Font.BOLD,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(email.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(contact.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(address.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7, BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
myDocument.add(new Paragraph("SKILLS",FontFactory.getFont(FontFactory.TIMES_BOLD,9, com.itextpdf.text.Font.BOLD,BaseColor.DARK_GRAY )));
table.setHeaderRows(1);
table.addCell(skills1.getText());
table.addCell(skills2.getText());
table.addCell(skills3.getText());
table.addCell(skills4.getText());
myDocument.add(table);
myDocument.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
myDocument.add(new Paragraph("QUALIFICATIONS", FontFactory.getFont(FontFactory.TIMES_BOLD,9, com.itextpdf.text.Font.BOLD, BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(college.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(qualiA.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(qualiB.getText(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
myDocument.add(new Paragraph("WORK EXPERIENCE",FontFactory.getFont(FontFactory.TIMES_BOLD,10, com.itextpdf.text.Font.BOLD,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph(""+work.getSelectedItem(),FontFactory.getFont(FontFactory.TIMES_BOLD,7,BaseColor.DARK_GRAY)));
myDocument.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
myDocument.add(new Paragraph("REFERENCES",FontFactory.getFont(FontFactory.TIMES_BOLD,9, com.itextpdf.text.Font.BOLD,BaseColor.DARK_GRAY )));
myDocument.add(new Paragraph("Available upon request",FontFactory.getFont(FontFactory.TIMES_BOLD,6,BaseColor.DARK_GRAY )));
myDocument.close();
JOptionPane.showMessageDialog(null,"CV was successfully generated");
}
catch(Exception ex){
JOptionPane.showMessageDialog(null,ex);
}
}
}
});
}
public ImageIcon resize(String path){
ImageIcon myImg = new ImageIcon(path);
Image image = myImg.getImage();
Image newImage = image.getScaledInstance(200,200,Image.SCALE_SMOOTH);
ImageIcon finalImage = new ImageIcon(newImage);
return finalImage;
}
}

Explanation of the Code

Two tasks were required to be completed to build this project. One involved creating the GUI, and the other was retrieval of information from SQL database & updating the CV or Resume according to user’s input.

Let us look at the GUI first:

1. Our user interface consists of 12 textfields, a combo Box, & a 2 buttons.

2. We have provided 2 buttons, namely “Select Image” & “Generate Resume” respectively.

Moving to creating pdf file using the given information, we will apply the following:

1. First, we created an object of Document class.

2. Then we pass the object to getInstance method of PdfWriter class.

3. After that, we have added the desired content using add method from Document class. The content should be present between the open & close method of Document class.

4. Finally, we have saved the pdf by passing the address of folder to new instance of FileOutputStream, which is in turn a parameter of getInstance method of PdfWriter class.

Output

Main Interface

How To Develop A CV Builder Using Java

We have successfully developed a CV builder using Java that helps to generate a PDF file of Person’s CV with Swing used for GUI. This is a very efficient way to use the application to create a good looking resume in the pdf format.

 

More Java Projects>>>

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *