# detectDocumentByName method

DetectedDocument detectDocumentByName(

1. DocumentImage image,
2. String? documentName,
3. Rectangle detectionZone

)

Detects a document with specified name on a delimited area of the specified DocumentImage and returns a DetectedDocument. Important: The relevant document template must be loaded before calling this method.

param image The source image to process. param documentName The name of the document to be searched for. Must be a key loaded in DocumentLibrary. param detectionZone A delimited area in the image where to search for the document. Default is the full image. Output corners are in the full image referential. return Detected document in the image throws DocumentException An error has occurred during Document Library execution.

## Implementation

    DetectedDocument detectDocumentByName(DocumentImage image, String? documentName, Rectangle detectionZone) {
      Pointer<Char>? pDocumentName = documentName?.toNativeUtf8().cast<Char>();
      DetectedDocument detectedDocument = DetectedDocument();
      try {
        var err = documentSDK.id3DocumentDetector_DetectDocumentByName(_pHandle.value, image.handle, pDocumentName ?? nullptr, detectionZone.handle, detectedDocument.handle);
        if (err != DocumentError.success.value) {
          detectedDocument.dispose();
          throw DocumentException(err);
        }
        return detectedDocument;
      } finally {
        if (pDocumentName != null) {
          calloc.free(pDocumentName);
        }
      }
    }