Hai,
I am using filereader for get file name. i can get pdf page count but if i choose large size pdf its cannot work. i have this error
This is my code
<input className="file-input" id="file" ref={ref} type="file" accept="application/pdf" multiple name="files[]" onChange={Retrive_file} />;
const Retrive_file = (e) => { e.preventDefault();
for (let i = 0; i < e.target.files.length; i++) { var file = e.target.files[i]; if (file.type.split("/")[1] != "pdf") { setError("Choose only PDF files"); return false; } else if (file.size < 1000) { setError("Choose valid PDF files"); return false; } const files = e.target.files; const reader = new FileReader(); reader.fileName = file.name; reader.fileSize = file.size; reader.readAsDataURL(file); reader.onloadend = (readerEvt) => { var data1 = readerEvt.target.result.split(",")[1]; var binaryBlob = atob(data1); const pagecount = binaryBlob.match(/\/Type[\s]*\/Page[^s]/g).length; pdfpagecount = [...pdfpagecount, pagecount]; readerEvt.target["checked"] = false; readerEvt.target["PageCount"] = pagecount; var data = pagecount; }; } };
How can i get page count in large pdf with filereader