Save results on the same node id

Created on 13 October 2023, almost 2 years ago

When I create or update a content type with a field mapped for OCR, I got a new node with the results.

is it possible to have the results saved on the same node id that has the file filed to be processed?

The goal is to have the PDF content on the same node id that has the original PDF.

thanks

✨ Feature request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

πŸ‡΅πŸ‡ΉPortugal jrochate

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jrochate
  • Hi sir, thanks for raised issue. i new in drupal, may i know what OCR do you used, Google or Openai? actually i try using this module for Google and Openai, but i got Page Not Found. any setting i have missing? thank for your help.

  • πŸ‡΅πŸ‡ΉPortugal jrochate

    Create a new issue with your request, as your question has nothing related to the original post.

  • Hi sir, same goal with me to have the PDF content on the same node id that has the original PDF.

    may i know, what OCR do you use? because i try use Google Document AI and OpenAI, i got Page Not Found. any setting i have missing? using Mindee OCR module is no problem. i am new in drupal. thanks for your help.

    Type page not found
    Date Thursday, October 12, 2023 - 16:43
    User admin
    Location http://localhost/ocr2/admin/config/structure/document-ocr/processors/new...
    Referrer http://localhost/ocr2/admin/config/structure/document-ocr/processors
    Message /ocr2/admin/config/structure/document-ocr/processors/new/google_document_ai/configuration
    Severity Warning
    Hostname ::1
    Operations

  • πŸ‡ΊπŸ‡ΈUnited States cameron prince

    Here's an example event subscriber which might work for you:

    /**
     * Provides the DocumentOcrDestinationEventSubscriber class.
     */
    class DocumentOcrDestinationEventSubscriber implements EventSubscriberInterface {
    
      /**
       * The event subscriber to function mapping.
       */
      public static function getSubscribedEvents() {
        $events['document_ocr.task_create_desination_before'][] = ['setDestination'];
        return $events;
      }
    
      /**
       * Sets the Document OCR destination.
       */
      public function setDestination($event) {
        // Add code to look up the node to save to.
        $nid = 1234;
        if ($node = $this->entityTypeManager->getStorage('node')->load($nid)) {
          $event->setEntity($node);
        }
      }
    
    }
    

    The other alternative is to either override/extend or decorate the Document OCR process service.

  • πŸ‡·πŸ‡ΊRussia hohner89

    Hi! I have the same problem. I can't save OCR results in the same node, the module just creates new one for every jpeg file (I have multiple pictures in one node).
    Is it possible to update source node and concatenate results for all files in one destination field?
    Thanks.

Production build 0.71.5 2024