0

I have a pdf file on my local machine and I want to compare it with my http response which is in pdf format. I am new to this and I have no idea how to do it. Can someone please suggest how can I do it. Please find below my code:

/******Get the document********/
String urlDoc = "https://abcd/v1/requests/"+order.request.id+"/"+"document";
                
HttpWebRequest requestDoc = (HttpWebRequest)WebRequest.Create(urlDoc);
requestDoc.Headers.Add("authorization", id_token);
requestDoc.Method = "GET";
                
var webResponse4 = requestDoc.GetResponse();
var webStream4 = webResponse4.GetResponseStream();
var responseReader4 = new StreamReader(webStream4);
var response4 = responseReader4.ReadToEnd();
Report.Success("Response : " + response4.ToString());
Request reqs = JsonConvert.DeserializeObject<Request>(response4);

// Clean up the streams.
responseReader4.Close();

Output of this is in pdf format.

Filburt
  • 17,626
  • 12
  • 64
  • 115
ae2019
  • 1
  • 1
  • 2
    Define "compare". Do you want to compare the bytes of the two files (i.e., make sure they're identical)? Do you want to compare the actual contents of the PDFs and make sure they "look the same"? Or do you want to compare the contents of the PDFs and generate a report of the diffs? The first has been asked and answered a million times, I'm sure. The second and third are too broad to fit into one question. – 41686d6564 stands w. Palestine Jun 14 '21 at 22:43
  • By the way, you should dispose `webResponse4` and `responseReader4` with a `using` block – Charlieface Jun 14 '21 at 22:54
  • Save it to disk then https://stackoverflow.com/questions/1358510/how-to-compare-2-files-fast-using-net – mjwills Jun 14 '21 at 23:01

1 Answers1

0

Compare the files using file hashes

Use the MD5 file hashing method to hash files. Use the code here

Kye
  • 76
  • 1
  • 10