WriteIn Element Example Exception

The example for the WriteIn element is not working for me and throws an exception: Value cannot be null. Parameter name: value.

The code to call this is simply using your JSON example and running:

var engine = new OmrEngine();
// markup path using your JSON file contents
GenerationResult res = engine.GenerateJSONTemplate(markupPath); 

Is this an error on my part, or is the example incorrect?

Thanks!

@Shonn

We are checking and fixing the examples given in the documentation and will let you know as soon as task is done. Please spare us some time.

Is this issue resolved yet? If this issue hasn’t been resolved yet, that’s fine but do you have an alternative for me to scan text that is printed in a specific position rather than handwritten??

I just need somewhere on the Image or PDF that I can put an ID number which would be different per person who downloads the PDF, then when they upload their picture to process with the OMR file it will read in the printed ID number.

Thanks!

@Shonn

Aspose.OMR does not provide feature to scan images. You need to use Aspose.OCR in order to do that. Please check the below documentation article:

What?? I’m confused…You are literally showing an example right here and your example it isn’t working. Generating the template|Documentation

What I was asking is: has this been fixed yet? If not, will scanning printed text work instead?

@Shonn

Sorry for the confusion. By scanning image portion, we assumed that you wanted to scan a portion of the image to extract text before performing OMR to process the records. Nevertheless, the WriteIn related examples are being investigated at the moment and the task is logged under the ticket ID OMRNET-407 in our issue management system. We will let you know as soon as it is resolved. We again apologize for the inconvenience and confusion caused by our previous reply.

No worries, I’m probably not being clear in what I’m asking. I don’t want to scan a portion of the image to extract text before performing the OMR. I want to extract the text during the OMR processing the same way I’m extracting the fill-in-the-bubble answers. The difference is, the upload will have typewritten text instead of handwritten text. Does that make more sense?

@Shonn

Thanks for further elaborating the requirements. We have logged this information along with the ticket and will surely inform you as soon as it is investigated.

@Shonn

We would like to share with you that

  1. Documentation have been updated. Instead of partial write-in example, we placed a full version.
  2. In order to support dynamic data (e.g.: student_id), you must update config between each call.
    Best practice would be to use Object-oriented call (GenerateTemplate | Aspose.OMR for .NET API Reference):
        var engine = new OmrEngine();

        IEnumerable<string> students = GetStudentsId();
        foreach (var student in students)
        {
            var config = new TemplateConfig()
            {
                Children = new List<BaseConfig>()
            {
                new PageConfig()
                {
                    Children = new List<BaseConfig>()
                    {
                        new ContainerConfig()
                        {
                            ColumnsCount = 2,
                            Children = new List<BaseConfig>()
                            {
                                new BlockConfig()
                                {
                                    Column = 1,
                                    Children = new List<BaseConfig>()
                                    {
                                         new ContentConfig()
                                        {
                                            Name = $"STUDENT_ID={student}"
                                        },
                                        new BarcodeConfig()
                                        {
                                            Value = student,
                                            Name = "STUDENT_ID",
                                            DrawCodetext = true,
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            };

            var result = engine.GenerateTemplate(config, new GlobalPageSettings());
            result.Save(@"C:\Users\User\Desktop\Students\", $"template_{student}");
        }
  1. For more information about Barcode element please follow up on documentation:
    Generating the template|Documentation
    as this will allow to encode student_id into page and successfully read upon recognition.
  2. Handwritten text could only be clipped and saved as image.
    Generating the template|Documentation
  3. if you do not have source information and just image - typewritten text could be recognized from image using Aspose.OCR

Thank you - is there a way to do this so that I can have just one OMR file but generate multiple Image or PDFs, or do I have to create an OMR file per student?

Reason I ask is that I might have hundreds of IDs in that foreach loop…

@Shonn

We are checking the feasibility of your requirement and will share our feedback with you soon.

@Shonn

Yes, in your case you need only one .omr file. The OMR file stores inside only information required for recognition. (e.g.:Barcode, stores width,height, type of barcode and position of barcode. Not it’s value.)

If you try to generate multiple images, changing only Content or Barcode value you will notice - .omr file is the same, but resulting .csv file will be different.

The example code you posted is creating an OMR and PNG file per student. So, I understand based on what you’re saying that I might only need one of those OMR files, but what I’m asking is: is there a way to generate 1 OMR file and then however many PNGs there are per student? Reason I ask is I’d like to use PDF generation and have all of the students in the PDF, but only one OMR file created at runtime and I’m not sure how to do that from this example.

Thanks!

@Shonn

The provided information has been recorded under the ticket and we will let you know as soon as it is analyzed.

@Shonn

As per our assumption, your project structure is:

    1. Student: John Smith
    • Test: Biology
      • Page 1: Personal info\Barcode
      • Page 2: Questions
      • Page 3: …
    1. Student: William Davis
    • Test: Biology
      • Page 1: Personal info\Barcode
      • Page 2: Questions
      • Page 3: …

If our assumptions are incorrect - please provide detailed descriptions for your project.

“Personal” approach:

  • John Smith.pdf
  • John Smith.omr
  • William Davis.pdf
  • William Davis.omr

Please use code below as an example:

foreach (var student in students)
        {
            var config = new TemplateConfig()
            {
                Children = new List<BaseConfig>()
                {
                    new PageConfig()
                    {
                        Name = $"first page of {student}",
                        Children = new List<BaseConfig>()
                        {
                            new ContainerConfig()
                            {
                                ColumnsCount = 2,
                                Children = new List<BaseConfig>()
                                {
                                    new BlockConfig()
                                    {
                                        Column = 1,
                                        Children = new List<BaseConfig>()
                                        {
                                             new ContentConfig()
                                            {
                                                Name = $"STUDENT_ID={student}"
                                            },
                                            new BarcodeConfig()
                                            {
                                                Value = student,
                                                Name = "STUDENT_ID",
                                                DrawCodetext = true,
                                            }
                                        }
                                    }
                                }
                            }
                        }                    
                    },
                    new PageConfig()
                    {
                        Name = $"second page  of {student}",
                        Children = new List<BaseConfig>()
                        {
                            new ContainerConfig()
                            {
                                ColumnsCount = 2,
                                Children = new List<BaseConfig>()
                                {
                                    new BlockConfig()
                                    {
                                        Column = 1,
                                        Children = new List<BaseConfig>()
                                        {
                                             new ContentConfig()
                                            {
                                                Name = $"Question 1"
                                            },
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var result = engine.GenerateTemplate(config, new GlobalPageSettings());
            result.SaveAsPdf(@"C:\Users\User\Desktop\Students\", $"template_{student}");
        }

“In bulk” approach:

  • students.pdf
  • students.omr

use the code below as an example:

        var engine = new OmrEngine();
        IEnumerable<string> students = GetStudentsId();

        var config = new TemplateConfig()
        {
            Children = new List<BaseConfig>(students.Count())
        };
        foreach (var student in students)
        {

            var firstStudentPage = new PageConfig()
            {
                Name = $"first page of {student}",
                Children = new List<BaseConfig>()
                        {
                            new ContainerConfig()
                            {
                                ColumnsCount = 2,
                                Children = new List<BaseConfig>()
                                {
                                    new BlockConfig()
                                    {
                                        Column = 1,
                                        Children = new List<BaseConfig>()
                                        {
                                             new ContentConfig()
                                            {
                                                Name = $"STUDENT_ID={student}"
                                            },
                                            new BarcodeConfig()
                                            {
                                                Value = student,
                                                Name = "STUDENT_ID",
                                                DrawCodetext = true,
                                            }
                                        }
                                    }
                                }
                            }
                        }
            };
            var secondStudentPage = new PageConfig()
            {
                Name = $"second page of {student}",
                Children = new List<BaseConfig>()
                        {
                            new ContainerConfig()
                            {
                                ColumnsCount = 2,
                                Children = new List<BaseConfig>()
                                {
                                    new BlockConfig()
                                    {
                                        Column = 1,
                                        Children = new List<BaseConfig>()
                                        {
                                             new ContentConfig()
                                            {
                                                Name = $"Question 1"
                                            },
                                        }
                                    }
                                }
                            }
                        }
            };

            config.Children.Add(firstStudentPage);
            config.Children.Add(secondStudentPage);
        }

        var result = engine.GenerateTemplate(config, new GlobalPageSettings());
        result.SaveAsPdf(@"C:\Users\User\Desktop\Students\", $"template_all");

In this case, you will indeed receive one .pdf and one .omr file. But it will come with handicap - file size overhead.

The size of .pdf and .omr will be multiplied according to student amount.

1 student .omr file = 2kb. 100 students .omr file = 200kb. 1000 students .omr file = 2mb.
Recognition would have to be in bulk too.

OK, I understand the example and appreciate it.

What if I have 2 million students and at runtime, the user wants to download a PDF for a particular student or group of students. Is there a way, instead, where I can create an OMR file with any affinity whatsoever to any student…but be able to just generate a PDF keeping the OMR the same? That’s really what I’m looking to do. I need to keep the OMR agnostic from any student data.

@Shonn

Thanks for the feedback. We have recorded your inquiry under the associated ticket and will look into it. We will soon let you know as soon as the requirements are analyzed. Please give us some time.

@Shonn

Thank you for provided information. Our recommendation would be to use the “personal” approach.

  1. .omr file can be cached and reused for any student.
    Content and absence of student data in .omr file are dependent of your template.
    If your template have same amount and type of elements for each student - .omr will be same:
    John Smith.pdf != William Davis.pdf
    John Smith.omr == William Davis.omr
    therefore you can use same .omr file for any student .pdf
  2. You can generate only .pdf file, if you want.
    Generation result for file system produce .omr file AND .pdf.png file.
    If you want to receive only .pdf file you can use Aspose.OMR.Generation.MemoryGenerationResult.GetPDF() to receive MemoryStream with .pdf file content.