How to display just first page of an uploaded document as an image with a link on it to the pdf file using JavaScript and html5. Is html2canvas or iframe need to use?
<html>
<head>
<title>Create a Form Dynamically with the JavaScript</title>
</head>
<body style="text-align: center">
<input type="file" onchange="previewFile()" /><br />
<img src="" height="200" alt="Image preview..." />
<script>
function previewFile() {
var preview = document.querySelector("img");
var file = document.querySelector("input[type=file]").files[0];
var reader = new FileReader();
reader.onloadend = function () {
preview.src = reader.result;
};
if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "";
}
}
</script>
</body>
</html>