tesseract-001

Tests that Tesseract OCR works

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/pdf-steps.xpl"/>
   <p:import href="https://xmlcalabash.com/ext/library/tesseract.xpl"/>
   <p:output port="result"/>
   <cx:pdf-to-images dpi="300">
      <p:with-input port="source"
                    href="../documents/example.pdf"/>
   </cx:pdf-to-images>
   <cx:tesseract language="eng" output-format="text"
                 debug-output="/dev/null"/>
   <p:wrap-sequence wrapper="text"/>
</p:declare-step>

Result

<text xmlns:t="http://xproc.org/ns/testsuite/3.0">PDF Text

This is a sample PDF document.

With an image.
</text>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="text">Wrong document element></s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/text">
         <s:assert test="empty(*)">Unexpected elements</s:assert>
         <s:assert test="contains(., 'This is a sample PDF document.')">Expected text missing</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

12 Jun 2026, Norm Tovey-Walsh
Created test.