Memory Stream Timeout Error

have been working on this code for the past few months in which I am attempting to take the byte array of a pdf document, pass it through a memory stream and eventually parse the stream using Aspose.Pdf in order to read it and make a comparison. However, any time I reach the part of the code that is writing the stream, I receive an error message stating that “timeouts are not supported on this stream”. Can you please assist with this or know anyone that can help?
using System;
using System.Collections.Generic;
using System.Text;

namespace xxxxxxxx.Models
{
public class PDFDocuments
{
public string documentA { get; set; }
public string documentB { get; set; }
}
}
// POST api/
[HttpPost]
public async Task PostAsync([FromBody] PDFDocuments documents)
{
var documentA = documents.documentA;
var documentB = documents.documentB;
var result = ComparePdfs(documentA, documentB);

        return result;
       
        
    }
    public static Bitmap ComparePdfs(string documentA, string documentB)
    {
        //Set License
        SetLicense();

// Load the PDF files

        byte[] firstpdfbytes = System.Text.Encoding.UTF8.GetBytes(documentA);

        MemoryStream stream1 = new MemoryStream(firstpdfbytes);

        stream1.Write(firstpdfbytes, 0, firstpdfbytes.Length);

        Document document = new Document();

        document.Pages.Add();

        document.Save(stream1);

        var doc1 = stream1;



        byte[] secondPdfBytes = System.Text.Encoding.UTF8.GetBytes(documentB);

        MemoryStream stream2 = new MemoryStream();

        stream2.Write(secondPdfBytes, 0, secondPdfBytes.Length);

        Document document2 = new Document();

        document2.Pages.Add();

        document2.Save(stream2);

        var doc2 = stream2;



        // Extract text from the first PDF

        Document pdfDocument1 = new Document(doc1);

        TextAbsorber textAbsorber1 = new TextAbsorber();

        pdfDocument1.Pages.Accept(textAbsorber1);

        string text1 = textAbsorber1.Text;

@erika318

The error looks related to C#, not with the Aspose.PDF. It looks like somewhere in your original program, you are trying to get/set the timeout for Stream. MemoryStream does not support setting or getting the ReadTimeout or WriteTimeout properties. Please try to use FileStream instead and see if it resolves the issue.

I can’t use Filestream because the pdfs that will be compared are coming from the front end of a web page where the user will drag and drop the files in a window and select a compare button which will fire off a request to an api that will trigger the comparison. Long story short the pdf files are not coming from a folder.

@erika318

If possible, would you kindly share a sample VS Project that is able to reproduce this scenario? We will use to replicate the issue and test in our environment.