Lesson 7: Scanned PDFs and Verification
Lesson No: 7
Working with Documents, Scanned PDFs and the Golden Rule of Verification
By Tanzeel-ur-Rahman (CodeHubb & MindCrafts_AI) Farooka (Sargodha)
Assalamu Alaikum wa Rahmatullahi wa Barakatuh!
Suppose you have fifty pages of a book, the syllabus of a madrasa, the policy of an institution or a client's contract. You want AI to prepare its summary, extract the important points, translate a passage or search for a particular issue.
If this material consists of a few paragraphs, it can be copied and pasted into the chat, but when a whole book or a document consisting of many pages is in front of you, this method becomes difficult.
For this very need, many AI platforms have the facility of File Upload. By attaching a file, questions can be asked about it and various kinds of work can be taken from it.
But here it is necessary to understand an important difference. Not every PDF is the same. In some PDFs, the text can be read by a computer, while in some there are only images of pages. Without understanding this difference, it is not appropriate to expect correct results from AI.
Come, today let us understand this topic with practical examples.
1. The Difference Between a Unicode PDF and a Scanned PDF
In general, PDF files appear in two major types in this respect.
First type: A Unicode or searchable-text PDF
In this type of PDF, the text is present in digital form. Its words can usually be selected with the help of a mouse or a finger, copied, and also pasted into another program.
For example, an Urdu article was written in MS Word on a computer, then it was saved in the form of a PDF. If the text has been saved correctly, the Urdu passage present in this PDF will be able to be selected and copied.
In such a file, obtaining the text is usually relatively easy for AI, provided the file is correct and the platform being used can read its text correctly.
Second type: A Scanned PDF
This is a PDF in which images of pages are included. For example, the pages of a book were scanned and a PDF was made.
In this file, the passage can appear clear to a human, but it is not necessary that the computer can recognise it as searchable text.
In such a situation, simply uploading the PDF does not necessarily obtain the required passage. To read the text, OCR (Optical Character Recognition) may be needed.
OCR is a technology that recognises the letters present in an image and changes them into readable and, in some cases, searchable text.
A simple experiment:
1. Open a PDF file.
2. Try to select a sentence from it.
3. Copy it and paste it into a text editor.
If the passage is copied correctly, it is highly likely that extractable text is present in the PDF.
If the passage cannot be selected, it is possible that the PDF is scanned, although there can also be some other reasons. Similarly, text being selectable is not a guarantee that the text of the whole file is correct; in some PDFs, both the original text and images of pages are present.
2. What Work Can Be Taken from AI on Both Types of PDF?
Many of the same kinds of work can be done on both types of files, but the method of reading them and obtaining information from them can be different.
On a Unicode or searchable-text PDF:
Having the summary of an article or a book prepared.
Searching for a particular topic or passage.
Having the important points written in order.
Having a translation done from Urdu to English or from English to Urdu.
Taking a comparative review of two documents.
Obtaining answers to questions on the basis of the information present in a document.
Having long text divided into headings and subheadings.
For example, material on the topic of "Following the Sunnah" is present in a book. You can tell AI to search for the passages related to this topic in the book and point out their pages or locations, provided the relevant tool can provide this information correctly.
On a scanned PDF:
The same work can be done, but first it is necessary to see whether AI can even read this file's pages or not.
If the AI tool has the ability to understand scanned pages in image form, it can try to analyse them directly. In some cases, extracting the text through OCR first is more appropriate.
OCR is especially useful for having passages transcribed from a scanned PDF, obtaining the text of old books, translating printed pages and searching for information present in a document.
However, if the pages are blurred, the letters are joined to one another, the passage is crooked or the Urdu letters are not clear, mistakes can come into the OCR.
Remember: When working on a searchable-text PDF, the main issue is usually obtaining the text correctly, whereas in a scanned PDF, the stage of recognising the text also becomes important.
3. The Problem of Urdu in OCR and AI's Mistakes
Recognising clean printed English text and reading a scanned page of an old Urdu book are not the same work.
In Urdu, the different shapes of letters, letters joining with one another, vowel marks, thin fonts, printing defects and, in some pages, the complex structure of Nastaliq can make recognising the text difficult.
For example, the original passage is this:
"Seeking knowledge is important for every Muslim."
But OCR can read it incorrectly and write it like this:
"Seeking knowledge is common for every Muslim."
Apparently only one word has changed, but the meaning has been affected.
Similarly, if a number, a date, a name, or a word of a verse or a hadith in a book is recognised incorrectly, the result can be greatly affected.
Here another weakness of AI comes before us. Sometimes, instead of saying about an unclear passage that it is not possible to read it correctly, it makes up an apparently suitable passage.
Therefore, it is not correct to regard text obtained from AI as equal to the original scan. Especially in religious, legal, historical and research material, comparison with the original passage is necessary.
4. Which AI Is Better for a Scanned PDF?
The answer to this question cannot be given simply by taking the name of an AI model, because here two separate abilities are important:
1. OCR: Changing the letters present in an image into correct text.
2. Document Understanding: Understanding the obtained text, preparing its summary and answering questions.
A tool can understand text very well, but it is not necessary that it can read every kind of scanned Urdu passage to the same standard.
Similarly, an OCR service can extract text correctly, but its ability to understand the meaning of a long document and prepare a quality summary of it can be limited.
Therefore, the choice of tool should be according to the nature of the document.
Google Gemini
According to Google's official technical material, Gemini's API has the facility to understand a PDF with both text and visual content. It can analyse a document's text, tables, charts and other visual elements. However, it does not follow from this that every Gemini model or the chat feature available to every user will read every scanned Urdu PDF correctly in the same way.
Claude
According to Claude's official documentation, in the analysis of a PDF, the visual content of the pages can also be used along with the text. Therefore, it is a choice worth considering for the analysis of documents. But a guarantee of correct recognition of a complex or unclear Urdu scan cannot be given.
ChatGPT
File upload and document analysis are available in ChatGPT, but the facility to read images present in a PDF can differ according to plan and feature. According to OpenAI's documentation, the availability of direct interpretation of a PDF's visual content is not the same in every plan; therefore, it should not be assumed that a scanned PDF uploaded in every account will be read in the same way.
Then how to make a better choice?
If the purpose is to extract the text of a scanned Urdu book, first look at the performance of the OCR. If the purpose is to obtain a summary, a translation or research points from the text, after that test AI's understanding and the correctness of its answer.
It is not correct to declare any one tool the best for every kind of Urdu PDF on this basis alone. The better method is that two or three available tools are tried on the same page and their results are matched against the original passage.
5. When Does AI "Cut Corners"?
In common language, we say that someone cut corners, that is, instead of completing the work, they showed apparently complete work.
In the case of AI as well, such a situation can come before us, although it is not necessary that this was done deliberately.
For example, you uploaded a scanned PDF of one hundred pages and said:
"Prepare a detailed summary of this entire book."
AI prepares a detailed answer, but it is possible that it did not obtain the text of some pages correctly, overlooked some parts, or made a general estimate on the basis of the available information.
The reader of the answer feels that the entire book has been studied, but the length of the answer is not proof that every page was read correctly.
Its second example is that you ask for a hadith to be transcribed from a scanned book. AI writes the words of a well-known hadith, but on the original page the words are different.
Here the reason for the mistake can be OCR, the interpretation of the text, or the process of AI preparing an answer on the basis of its own prediction.
Therefore, do not regard merely a confident answer, a detailed explanation or beautiful formatting as proof of correctness.
6. Practical Exercise: The Test of a Scanned Urdu PDF
Now do a practical experiment.
Step No. 1: Select one clean scanned Urdu page of a book or an article. Try to ensure that the passage is clear and that it contains no personal or confidential information.
Step No. 2: Upload this page into an AI tool that can understand images or a scanned PDF.
Step No. 3: Use this prompt:
> Role: You are a careful document analyst.
Task: Read the attached scanned page carefully and transcribe the text present in it in Urdu.
Conditions:
1. Keep the words, names, numbers and symbols of the original passage exactly as they are, as far as possible.
2. About a word that cannot be read clearly, write "unclear" instead of guessing about it.
3. Do not add any word or sentence from your own side.
4. If you are not certain about any passage, point this out.
5. After transcribing the text, write its brief summary under a separate heading.
Step No. 4: Match the text transcribed by AI against the original page. Look at these things in particular:
Have all the lines been transcribed?
Has another word been written in place of a word?
Are the names, dates and numbers correct?
Has any line or paragraph been left out?
Has an unclear word been completed from its own side?
Step No. 5: Try the same page in another available AI tool as well. Compare both results against the original page.
From this experiment, you will learn to what extent different tools read the same passage correctly.
Remember that obtaining a good result on one page is not a guarantee that that tool will be able to read the entire book to the same standard as well.
7. The Golden Rule of Verification
Now suppose you need a hadith from a scanned religious book. AI transcribed the passage and also told you the name of the book and the page number along with it.
Should the passage be accepted as correct merely because AI also wrote the reference?
No.
The reference can also be wrong, the page number can also be wrong, and a change can also come into the transcribed passage.
Therefore, for important information, adopt this method:
First step: Have the relevant passage transcribed by AI.
Second step: Search for that same passage in the original scan.
Third step: Compare the words, names, numbers and necessary symbols.
Fourth step: If the reference is important, verify it against the original text of the book or a reliable source.
Fifth step: If the passage is not clear, instead of regarding it as final, turn to a better-quality image or the original printed copy.
This same principle also applies to legal contracts, financial documents, research papers, historical books and other important material.
Lesson Summary
1. A PDF can contain searchable digital text and can also contain only images of pages.
2. Obtaining a passage from a searchable-text PDF is usually relatively easy.
3. To extract text from a scanned PDF, OCR or visual recognition may be needed.
4. Urdu Nastaliq passages, blurred pages and complex letters can create difficulties for OCR.
5. The accuracy of OCR and the ability to understand the text are two separate things.
6. Before declaring any AI tool the best for every kind of scanned Urdu PDF, a practical comparison is necessary.
7. A long or detailed answer is not a guarantee that AI has read the entire document correctly.
8. It is necessary to match important passages transcribed by AI against the original document — verify important information against the original source.
9. Verify the reference, page number, name, date and numbers separately.
10. Before uploading a sensitive document, review the privacy terms of the relevant platform.
Today's task: Have one scanned Urdu page read by two available AI tools, compare the results against the original passage and note how many mistakes each tool made.
Tell us in the comments: In your experience, which AI was better at reading scanned Urdu passages, and did it make a mistake in any word or line?
Tanzeel-ur-Rahman
#Lesson7 #DocumentAnalysis #ScannedPDF #OCR #UrduOCR #VerificationFirst #PromptEngineering #MindCraftsAI #CodeHubb
Join the WhatsApp channel for all previous lessons, and check the comments for Lesson 6.