PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDFKit supports detecting whether a PDF document is a scanned document (image document). Scanned documents are typically generated by scanners, where page content is stored as images rather than selectable text. ComPDFKit provides two levels of scanned document detection: document level and page level.
Use the CPDFDocument.isImageDoc() method to determine whether the entire PDF document is a scanned document. Here is an example:
CPDFDocument document = new CPDFDocument();
document.open("test.pdf");
bool isScannedDocument = document.isImageDoc(); // Returns true if it is a scanned document
if (isScannedDocument)
{
// This document is a scanned document, may need OCR processing to extract text
}Use the CPDFPage.isImagePage() method to determine whether a single page is a scanned page (image page). This method is suitable for mixed documents where some pages are scanned images and some pages are regular text. Here is an example:
CPDFDocument document = new CPDFDocument();
document.open("test.pdf");
for (int i = 0; i < document.PageCount; i++)
{
CPDFPage page = document.PageAtIndex(i);
bool isImagePage = page.isImagePage(); // Returns true if the page is a scanned/image page
if (isImagePage)
{
// This page is a scanned page, may need OCR processing to extract text
System.out.println("第 " + i + "页是扫描页");
}
}| Method | Level | Use Case |
|---|---|---|
CPDFDocument.IsImageDoc() | Document level | Determine if the entire document is a scanned document, suitable for quick document type filtering |
CPDFPage.IsImagePage() | Page level | Determine if a single page is a scanned page, suitable for processing mixed documents or page-by-page analysis |
A scanned document is a PDF file created by converting a paper document to an electronic document using a scanner or camera. The characteristic of such documents is that page content is stored as images, making it impossible to directly select or search text within. Identifying scanned documents helps determine whether OCR (Optical Character Recognition) processing is needed.