How do I convert byte[] into a PDF document in C#? I want to create a PDF file from the byte[] into c:/PDF/test.pdf
2 Answers
The simplest way is using File.WriteAllBytes:
File.WriteAllBytes(fileName, data); No need for opening streams, worrying about closing them properly etc - it does it all for you.
That's assuming data already contains the PDF document appropriately, of course. If you haven't already got a PDF, you'll need to tell us what's in the byte[]...
5 Comments
ammad khan
What if i want to convert docx binary to pdf binary
Jon Skeet
@ammadkhan: Then that's a completely different question. (There's no real conversion going on in this question, despite the way it's phrased. It's just about writing the existing PDF to disk.)
ammad khan
can you plz guide how it can be done any link or source to solve this problem I am facing
Jon Skeet
@ammadkhan: No; please don't spam comment threads with unrelated questions.
ammad khan
I understand can you at least email me the solution ?