An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
Hello TRẦN NGỌC UYỂN NHI,
Greetings! Thanks for raising this question in the Q&A forum.
There is currently no request parameter or service side option for output=pdf that detects existing native text and skips adding an overlay on those pages or regions. The Read model's searchable PDF feature works by running OCR across every page image you submit and embedding an invisible text layer at the detected word locations, it does not inspect the input PDF for an existing text layer first, so any page sent through analyze?output=pdf will always get an overlay regardless of whether it already had selectable text. Your plan to gate generation per page on the client side is the correct approach, since there is no equivalent server side flag to do this for you.
- Confirm there is no native text skip option
Since the Analyze operation for output=pdf only accepts the document and output format, there is no parameter such as a region mask, page filter, or a "skip if text exists" flag in the 2024-11-30 GA API surface. This answers your first question, the per-page gating you already planned is the recommended path, not a workaround for a missing feature, it is the actual intended approach for this scenario.
- Detect native text per page before deciding routing
Use a PDF library on the client to check whether each page already has an extractable text layer before deciding whether to send that page through Document Intelligence.
import fitz # PyMuPDF
doc = fitz.open("input.pdf")
pages_needing_ocr = []
for i, page in enumerate(doc):
text = page.get_text().strip()
if not text:
pages_needing_ocr.append(i)
Only the pages in pages_needing_ocr should be sent for OCR processing, exactly as your current plan describes.
- For mixed pages, flatten rather than try to merge two layers
For a single page that has both native text and a scanned image region containing text, do not try to combine the original native layer with a new OCR overlay on the same page, since the service has no concept of partial page processing and you would end up reconciling two independent coordinate systems by hand, which is fragile and exactly the kind of misalignment that breaks your redaction workflow. Instead, rasterize that specific page to a flat image, which strips its existing text layer entirely, then submit only that flattened image through analyze?output=pdf.
pix = page.get_pixmap(dpi=300)
pix.save(f"page_{i}_flattened.png")
Send page_{i}_flattened.png through the Read model with output=pdf, then in your final assembled document replace that original mixed page with the new OCR generated page rather than layering anything on top of the original. This gives you one single coherent text layer for that page with no duplication, at the cost of losing the original native text's exact font metadata, which is an acceptable tradeoff since your downstream use case only needs reliable, non overlapping text selection for building redaction masks.
- Reassemble the final document
Keep pages that were already fully native and untouched as is, replace pages that were fully image only with the direct output=pdf result for that page, and replace mixed pages with the flattened and reprocessed version from step 3, then merge all pages back into a single PDF using a library such as PyMuPDF or PDFBox.
If this answer helps you kindly accept the answer which will help others who have similar questions.
Best Regards,
Jerald Felix.