0

Im currently working in a rather old system where we have already implemented functions for getting the filepath to a pdf which we launch to view in a browser. My current task is to implement functionality for us to also launch a pdf in our new storage (azure blob) which i will recieve as a Byte[]. I have a functioning version where i create a temporary pdf which i launch the same way as the older implementation and storage, but it is preferable if i could implement functionality where i do not have to create a physical copy of the pdf.

I have not gotten this to work sadly, does anyone have any idea if it is possible to save a pdf in memory without creating a physicla pdf file, or directly launch a byte[] as a pdf to the browser?

I would love for it to work similar to this where i have a local pdf document, but without creating the document itself.

string app = @"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";

string temp = "pdf as base64";

byte\[\] bytes = Convert.FromBase64String(temp);

System.IO.File.WriteAllBytes("newTest.pdf", bytes);

string path = Path.GetFullPath("newTest.pdf");

// whatever condition to launch
System.Diagnostics.Process.Start(app, path);
Oshawott
  • 539
  • 5
  • 12
  • 1
    With Chrome, navigating to "data:application/pdf;base64, BASE64_ENCODED_PDF_DATA" might work. – Klaus Gütter Jan 09 '23 at 13:23
  • I assume you mean "creating a local file" or "copy the file to the local file system". I would interpret "physical copy of the pdf" to mean printing the file to paper. – JonasH Jan 09 '23 at 13:38
  • what is your back-side? Is this web api, asp.net or what? If this was some browser app that downloads bytes from Web Api then saves it locally and opens it - this is possible. Or something like this https://stackoverflow.com/questions/35038884/download-file-from-bytes-in-javascript – T.S. Jan 09 '23 at 13:57
  • To clarify what i meant with physical copy => Local file. I did not want to create a pdf file that was stored anywhere. – ManaCactus Jan 10 '23 at 12:06
  • Now got a request to open it in adobe acrobat instead, which means that i most likely will have to create a temporary pdf anyways... – ManaCactus Jan 10 '23 at 12:20

0 Answers0