I have a Windows app created in VS2012. I'm calling a web service that is returning a pdf as a byte array. I want to convert the array back to a pdf and display it to the user without having to save it as a file first.
Convert byte array to PDF without saving as a file
Collapse
X
-
-
That's the problem. I haven't found many examples for a Windows form that I could test with. I did try this, but I'm missing whatever makes the document display.
Code:Dim arrPage() As Byte = Nothing arrPage = pdfWS.RetrieveDocument(docID, docRefID) Dim ms As MemoryStream = New MemoryStream ms.Write(arrPage, 0, arrPage.Length)
Comment
-
Without adding a reference to a PDF reader of some sort then you are pretty much stuck with writing it to a file and then calling whatever PDF reader is installed on the machine.
The following code will write your byte array to a pdf document, then load it in the currently installed pdf reader (adobe reader).
Otherwise you would need a PDF control (preferably a native .net one) with it's own methods for accepting a byte array directly from and into its own buffers.Code:My.Computer.FileSystem.WriteAllBytes("MyPDF.pdf", MyByteArray, False) System.Diagnostics.Process.Start("MyPDF.pdf")
That might be expensive. One like the following might work:
But you need $299.00Comment
Comment