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

I am trying to develop a web page where I want to upload a PDF file to a web page, get the values of its fields then render them into the web page fields using JavaScript. I started with the following code but I can not get the value of the PDF fields. May I ask for a sample code on how to do this

We can’t see any code. Perhaps a repo would be better.

I’m no expert, but right off the bat I have some questions.

What do you mean “upload from a web page” - usually you upload to or you download from. Also, I’ve never done it before but I’m sure there is a library that can read PDF files. Also, PDF files can be text but can also just be images, in which case you’d need some kind of OCR. But I’m no expert. I’m assuming this is encoded as some kind of a text form?

Sorry for the typo it is uploading to. I want to export the data from a PDF file fields that’s why I want to upload it then extract the information from its fields. This is again the code. For some reasons it did not appear on my previous post

<html>
<head>
<script src="jquery-2.1.4.js"></script>
<script src="jspdf.min.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</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");
		var doc = new jsPDF(input.files[0]);            		
		alert("1");
            		//var fReader = new FileReader();
            		//fReader.readAsDataURL(input.files[0]);
            		// console.log(input.files[0]);
            		//fReader.onloadend = function (event) {
                		//convertDataURIToBinary(event.target.result);
            }
</script>
</body>
</html>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

We can’t test this without setting up the whole project. Please publish this into a github repo and include a pdf file that has the field you are trying to parse.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.