By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,238 Members | 1,485 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,238 IT Pros & Developers. It's quick & easy.

Convert byte array to PDF without saving as a file

P: 4
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.
Nov 27 '12 #1
Share this Question
Share on Google+
3 Replies


P: 6
Can you please put in the code you tried so far.

Thank you.
Nov 27 '12 #2

P: 4
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.

Expand|Select|Wrap|Line Numbers
  1.  Dim arrPage() As Byte = Nothing
  2.  arrPage = pdfWS.RetrieveDocument(docID, docRefID)
  3.  
  4.  Dim ms As MemoryStream = New MemoryStream
  5.  ms.Write(arrPage, 0, arrPage.Length)
  6.  
Nov 28 '12 #3

!NoItAll
100+
P: 296
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).

Expand|Select|Wrap|Line Numbers
  1. My.Computer.FileSystem.WriteAllBytes("MyPDF.pdf", MyByteArray, False)
  2. System.Diagnostics.Process.Start("MyPDF.pdf")
  3.  
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.
That might be expensive. One like the following might work:

http://www.softpedia.com/get/Program...r-dotNET.shtml

But you need $299.00
Dec 1 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.