DEV Community

Cover image for Code to Make CV Generator: make By Mirza Hanzla 😎
DevTeam
DevTeam

Posted on

Code to Make CV Generator: make By Mirza Hanzla 😎

World's Most Advanced CV Generator: How It Works and Why You Need It

Introduction

In today's competitive job market, a well-crafted CV is crucial. A CV generator can simplify the process, allowing you to create professional, customized CVs quickly. This article introduces a project called "World's Most Advanced CV Generator" that I developed using HTML, CSS, JavaScript, and a few external libraries. It allows users to input their details and generate a visually appealing CV with the option to download it as an image. Let's dive into the components of the code and how it all comes together.

Project Overview

This CV generator is designed to be interactive and easy to use. The user interface is sleek, with smooth animations and a responsive layout that adapts to various screen sizes. The generator provides a form for users to input their details, such as name, position, email, phone, and more. Once the information is entered, the user can generate a CV that is displayed on the screen and download it as an image.

Key Features

  • User-Friendly Interface: The generator features an intuitive and minimalistic design that makes it easy for users to input their information.
  • Responsive Design: The layout is fully responsive, ensuring that the CV generator looks great on all devices, from desktops to mobile phones.
  • Smooth Animations: The use of CSS animations enhances the user experience by providing smooth transitions and interactions.
  • CV Download Option: Users can download their generated CV as a PNG image file, making it easy to share or print.

Code Breakdown

1. HTML Structure

The HTML code defines the basic structure of the CV generator. It includes a container for the main content, a circle that acts as a button to reveal the form, the form itself, and a section where the generated CV is displayed.

<div class="container">
    <div class="circle" onclick="showForm()">
        <i class="fas fa-edit"></i>
    </div>
    <div class="form-box animate__animated" id="form-box">
        <!-- Form fields for user input -->
        <button class="close-btn" onclick="hideForm()"><i class="fas fa-times"></i></button>
        <h2>Enter Your CV Details</h2>
        <input type="text" id="name" placeholder="Name">
        <input type="text" id="position" placeholder="Position">
        <input type="text" id="email" placeholder="Email">
        <input type="text" id="phone" placeholder="Phone">
        <textarea id="about" placeholder="About Me"></textarea>
        <textarea id="experience" placeholder="Experience"></textarea>
        <textarea id="education" placeholder="Education"></textarea>
        <button onclick="generateCV()">Generate CV</button>
    </div>
    <div id="cv-display">
        <button onclick="downloadCV()">Download CV</button>
        <!-- Display the CV details here -->
        <h2>Curriculum Vitae</h2>
        <h3>Name</h3>
        <p id="cv-name"></p>
        <h3>Position</h3>
        <p id="cv-position"></p>
        <h3>Email</h3>
        <p id="cv-email"></p>
        <h3>Phone</h3>
        <p id="cv-phone"></p>
        <h3>About Me</h3>
        <p id="cv-about"></p>
        <h3>Experience</h3>
        <p id="cv-experience"></p>
        <h3>Education</h3>
        <p id="cv-education"></p>
    </div>
</div>
Enter fullscreen mode Exit fullscreen mode

2. CSS Styling

The CSS provides the styles that give the CV generator its polished look. It defines the layout, typography, and animations used throughout the project. The use of CSS variables and gradient backgrounds helps create a visually appealing and cohesive design.

body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #e9ecef 0%, #f5f7fa 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.container {
    text-align: center;
    position: relative;
}
.circle {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, #ff6b6b, #f06595);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.5s ease;
}
.circle:hover {
    transform: scale(1.1);
}
.form-box {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 15px;
    position: absolute;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 800px;
}
.form-box h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 28px;
    font-weight: 700;
}
.form-box input, .form-box textarea {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
    border: 1px solid #ddd;
}
.form-box button {
    padding: 12px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
Enter fullscreen mode Exit fullscreen mode

3. JavaScript Functionality

The JavaScript code handles the interactivity of the CV generator. It includes functions to show and hide the form, populate the CV with the user's input, and download the generated CV as an image.

function showForm() {
    document.getElementById('form-box').style.display = 'block';
}

function hideForm() {
    document.getElementById('form-box').style.display = 'none';
}

function generateCV() {
    document.getElementById('cv-name').innerText = document.getElementById('name').value;
    document.getElementById('cv-position').innerText = document.getElementById('position').value;
    document.getElementById('cv-email').innerText = document.getElementById('email').value;
    document.getElementById('cv-phone').innerText = document.getElementById('phone').value;
    document.getElementById('cv-about').innerText = document.getElementById('about').value;
    document.getElementById('cv-experience').innerText = document.getElementById('experience').value;
    document.getElementById('cv-education').innerText = document.getElementById('education').value;
    document.getElementById('cv-display').style.display = 'block';
    document.getElementById('form-box').style.display = 'none';
}

function downloadCV() {
    html2canvas(document.getElementById('cv-display')).then(function(canvas) {
        var link = document.createElement('a');
        link.href = canvas.toDataURL('image/png');
        link.download = 'cv.png';
        link.click();
    });
}
Enter fullscreen mode Exit fullscreen mode

4. External Libraries

The project utilizes several external libraries to enhance functionality and styling:

  • Google Fonts: Provides custom fonts (Roboto, Lora, and Open Sans) for a professional and clean appearance.
  • Font Awesome: Adds vector icons, such as the edit icon in the circle.
  • Animate.css: Provides predefined CSS animations for elements like the form box.
  • Bootstrap: Ensures a responsive layout and styling.
  • GSAP: Offers advanced animations for a smooth user experience.
  • html2canvas: Converts the CV displayed on the screen into an image that users can download.

5. How It Works

  1. User Interaction: The user clicks the circle button, which triggers the showForm function to display the input form.
  2. Input Capture: The user fills in their details (name, position, etc.) and clicks "Generate CV."
  3. CV Generation: The generateCV function populates the CV display area with the user's information.
  4. Download Option: If the user is satisfied with their CV, they can click the "Download CV" button, which triggers the downloadCV function to save the CV as a PNG image.

Conclusion

This CV generator is a powerful tool for creating professional CVs effortlessly. The combination of HTML, CSS, and JavaScript, along with external libraries, ensures a seamless and polished experience. Whether you're a developer looking to build similar projects or a job seeker needing a quick and stylish CV, this project showcases how to achieve both functionality and aesthetics in web development.


Top comments (0)