I have a string like 0x255044462D312E330D0A312030206F626A0D0
and I've tried to convert it to a PDF
.
Code:
var inputStr="my hex string";
pdfFile = Encoding.Unicode.GetBytes(inputStr).ToArray();
return new FileContentResult(pdfFile, "application/pdf");
It's not working ( "Failed to load PDF document" is the message I get ). What am I doing wrong? I've also tried to change response
:
Response.ClearHeaders();
Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Length", pdfFile.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; filename=sample.pdf");
Response.BinaryWrite(pdfFile);
Response.Flush();
Response.End();
Update
I don't know how the string was initially encoded
Update 2
So I'm receiving "-2" because of someone who thought this questions is a duplicate ( he deteled his answer by the way ) ? Thank you