RecognitionText is Empty post Compression

Hi Team,

In the below code output.RecognitionText become Empty post compression. Can you pls tell what is the issue with the below code

 static byte[] Decompress(MemoryStream InputMemStream)
	{
		try
		{
			InputMemStream.Position = 0;

			using (var outputStream = new MemoryStream())
			{
				using (var decompressStream = new BrotliStream(InputMemStream, CompressionMode.Decompress))
				{
					decompressStream.CopyTo(outputStream);
				}
				return outputStream.ToArray();
			}
		}
		catch (Exception ex)
		{
			throw new Exception("--> at Decompress() " + ex.Message + " StackTrace " + ex.StackTrace + ex?.InnerException?.Message);
		}
	}
	static byte[] Compress(byte[] bytes)
	{
		using (var memoryStream = new MemoryStream())
		{
			using (var brotliStream = new BrotliStream(memoryStream, CompressionLevel.Fastest))
			{
				brotliStream.Write(bytes, 0, bytes.Length);
			}
			return memoryStream.ToArray();
		}
	} 
	public static void CompressionText(string path = "")
	{

		RecognitionSettings drsMultiplePage = new()
		{
			AllowedCharacters = CharactersAllowedType.ALL,
			LinesFiltration = true,
			UpscaleSmallFont = true,
			DetectAreasMode = DetectAreasMode.COMBINE,
			ThreadsCount = 0,

		};

		AsposeOcr api = new AsposeOcr();
		License lic = new License();
		lic.SetLicense("Aspose.Total.NET.lic");
		string Filename = "2pagetiff.tiff";
		string imgPath = @"C:\\Users\\gpatil\\Downloads\\" + Filename;

		PreprocessingFilter pp = new PreprocessingFilter();

		OcrInput ocrInput = new OcrInput(InputType.TIFF, pp);
		ocrInput.Add(imgPath);
		Stopwatch stopwatch = new Stopwatch();
		stopwatch.Start();

		List<RecognitionResult> result = new List<RecognitionResult>();
		try
		{
			result = api.Recognize(ocrInput, drsMultiplePage);

		}
		catch (Exception ex)
		{
			Console.WriteLine(ex);
		}

		string inputStr = JsonConvert.SerializeObject(result);

		string strResult = string.Empty;

		byte[] inputBytes = Encoding.UTF8.GetBytes(inputStr);

		using (MemoryStream msstream = new MemoryStream(Compress(inputBytes)))
		{
			strResult = Encoding.UTF8.GetString(Decompress(msstream));

			var output = JsonConvert.DeserializeObject<List<RecognitionResult>>(strResult);
		}
	}

@Gpatil

Would you please share your sample image with us as well so that we can generate a ticket in our issue management system to investigate this case?

Hi @asad.ali ,

Kindly find the attached tiff file. Their is no impact in the end searchable pdf output as such but the property become empty post serialization and compression.

DetectMode also changes to Document. Those are two, I noticed.

OnePage.tiffPHOTO.pdf.zip (1.4 MB)

@Gpatil

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): OCRNET-816

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.