Why the pdf document is not having any data inside it

47 Views Asked by At

project: certificate generator

I have a certificate template.png file in the folder directory.

Link for the template file: https://drive.google.com/file/d/1UgYkO-VOXvCUjBkdbSEDOGVd8szZXZ0z/view?usp=sharing

Here I am looking to get a new pdf file using the above template file along with the name inserted if I click the generate button.

I should use pdf-lib for creating the pdf file.

I need to do these following things:

  1. Fetch the certificate from file system
  2. load the document using the PDFDocument object
  3. load the font by fetching from file system
  4. Embed the font resource in the pdf object
  5. insert the test from the input box at the empty area where the name goes (with x,y and font-size)
  6. save the file
  7. create a new file object in JavaSScript and download it using the saveAs(fileName)

Frontend Pic: enter image description here

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Certificate Generator</title>
    <link href="styles.css" rel="stylesheet" />

    <script src="https://unpkg.com/pdf-lib/dist/pdf-lib.js"></script>
    
    <script type="module" src="FileSaver.js"></script>
  </head>
  <body>
    <section>
      <div class="container">
        <img
          src="https://codedamn.com/assets/images/red-logo.png"
          width="75"
          alt="codedamn logo"
        />
        <p>Get your certificate of</p>
        <h1>Project Certificate Generator</h1>
        <p class="name-text">Enter Your Name</p>

        <input type="text" id="participant-name" placeholder="Steve" />
        <button id="proceed">Generate Certificate</button>
      </div>
    </section>
  </body>
  <!-- <script src="index.js"></script> -->
</html>
0

There are 0 best solutions below