# How to upload a PDF file to a web page, get the PDF fields values and render them into the same web page fields using JavaScript

**URL:** <https://pdfjs.community/t/how-to-upload-a-pdf-file-to-a-web-page-get-the-pdf-fields-values-and-render-them-into-the-same-web-page-fields-using-javascript/1484>\
**Category:** Technical Support\
**Created:** [March 18, 2022, 2:22pm UTC](https://pdfjs.community/t/how-to-upload-a-pdf-file-to-a-web-page-get-the-pdf-fields-values-and-render-them-into-the-same-web-page-fields-using-javascript/1484 "2022-03-18T14:22:50Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![samehkm](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@samehkm](https://pdfjs.community/u/samehkm)\
**Post date:** [March 18, 2022, 2:22pm UTC](https://pdfjs.community/t/how-to-upload-a-pdf-file-to-a-web-page-get-the-pdf-fields-values-and-render-them-into-the-same-web-page-fields-using-javascript/1484/1 "2022-03-18T14:22:50Z")

</div>

**Which product are you using?**

Visual Studio Code  
**PDF.js Express Version**

**Detailed description of issue**  
{I am trying to develop a web page where I want to upload a PDF file to this web page, get the values of the PDF fields then insert them into the web page fields using JavaScript. May I ask for a sample code on how to do this

I tried the following code but did not work}

**Expected behaviour**  
{Provide a screenshot or description of the expected behaviour}

**Does your issue happen with every document, or just one?**  
{Answer here}

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
{

```
<head>

    <script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.13.216/build/pdf.min.js"></script>

</head>

<body>

    <input type="file" id="file-id" name="file_name" onchange="ExtractText();">

    <!-- a container for the output -->

    <div id="output"></div>

    <script>

        function ExtractText() {

            var input = document.getElementById("file-id");    

            //alert(input.files[0].name);

            pdfjsLib.getDocument('./SamplePDF.pdf').then(doc=>{

                console.log("This PDF has "+doc._pdfInfo.numPages+" pages");

            });

        }

    </script>

</body>

```

}

---

_[View the full topic](https://pdfjs.community/t/how-to-upload-a-pdf-file-to-a-web-page-get-the-pdf-fields-values-and-render-them-into-the-same-web-page-fields-using-javascript/1484)._
