Image to XML C#

Sometimes the data can exist in the form of images. You might need to process such data thus the image to XML conversion can be helpful in such scenarios. You can convert an image in JPG, PNG, or other image formats to XML format programmatically in C#. This article covers how to convert an image to XML by performing OCR operation programmatically in C#.

JPG or PNG Image to XML Converter with OCR in C# – API Installation

You can perform optical character recognition over the images as well as other file formats supported by Aspose.OCR for .NET API. Simply download the DLL file from the New Releases section or run the following NuGet installation command:

PM> Install-Package Aspose.OCR

Convert Image to XML Data with OCR Programmatically in C#

You can process an image with OCR and export the extracted information in XML format with the following steps:

  1. Create an instance of the AsposeOcr class.
  2. Recognize the image while initializing a RecognitionSettings class object.
  3. Print the extracted information in XML format.

The code snippet below demonstrates how to convert an image to XML data using C#:

Convert JPG or PNG Image to an XML File in C#

In certain scenarios, while extracting XML data from an image, you may need to create an output file containing the XML data instead of printing it to the console output. You need to specify the file path and the save format for the output file. The following steps explain the process to convert a JPG or PNG image to an XML format file:

  1. Initialize an instance of the AsposeOcr class.
  2. Process the image with OCR while creating an object of the RecognitionSettings class.
  3. Save the output file in the XML format.

The following code sample shows how to convert a JPG, or a PNG image to XML format programmatically in C#:

Get Free API License

You can check all the features of the API by requesting a free temporary license.

Conclusion

In this article, you have learned how to convert a JPG or PNG image to XML data with OCR programmatically in C#. Moreover, you can take a look at other OCR capabilities of the API by going through the documentation space. Please feel free to reach out to us at the forum in case you have any ambiguities or concerns.

See Also

Convert Image to JSON with OCR in C#