0

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

1

2 Answers 2

6

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[]...

Sign up to request clarification or add additional context in comments.

5 Comments

What if i want to convert docx binary to pdf binary
@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.)
can you plz guide how it can be done any link or source to solve this problem I am facing
@ammadkhan: No; please don't spam comment threads with unrelated questions.
I understand can you at least email me the solution ?
0

If the data is already known to be pdf, it's simple.

System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Create); stream.write(data, 0, data.Length); stream.Close(); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.