• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript to detect scanned PDFs and ISO Standards

Community Expert ,
Dec 10, 2021 Dec 10, 2021

Copy link to clipboard

Copied

Hi

 

I'd like to know if I can use JavaScript to detect if a PDF conforms to any ISO Standard (PDF/X, PDF/E, PDF/A mainly) and also to detect if it's a "scanned PDF" or not.

 

I  know that I can use a Preflight profile to detect if a PDF not conforms to an ISO Standard, but I need to detect if a PDF conforms to an ISO Standard.

 

Thank you

TOPICS
Edit and convert PDFs , JavaScript , Scan documents and OCR , Standards and accessibility

Views

521

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 10, 2021 Dec 10, 2021

No, JavaScript has no such option, beyond running a Preflight profile on the file.

You can check if it contains any "real" text, though. If not, it's likely (although not necessarily) a scanned document.

To do that you can run the following script:

 

var fileHasText = false;
for (var p=0; p<this.numPages; p++) {
	var numWords = this.getPageNumWords(p);
	if (numWords>0) {
		fileHasText = true;
		break;
	}
}
if (fileHasText) app.alert("There is text in this file.",3);
else app.alert("There's NO te
...

Votes

Translate

Translate
Community Expert ,
Dec 10, 2021 Dec 10, 2021

Copy link to clipboard

Copied

LATEST

No, JavaScript has no such option, beyond running a Preflight profile on the file.

You can check if it contains any "real" text, though. If not, it's likely (although not necessarily) a scanned document.

To do that you can run the following script:

 

var fileHasText = false;
for (var p=0; p<this.numPages; p++) {
	var numWords = this.getPageNumWords(p);
	if (numWords>0) {
		fileHasText = true;
		break;
	}
}
if (fileHasText) app.alert("There is text in this file.",3);
else app.alert("There's NO text in this file.",3);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines