Solved

How to create a PDF file using binary strings in C#? or converting Binary String to System Stream, etc.

Posted on 2008-06-24
2
2,309 Views
Last Modified: 2012-06-27
So i receive a xml from a web service.  The web service documentation claims that

( The response element returns the binary string that contains the pdf Summary Report image. You must have a method for converting the binary string to human-readable PDF file.)

The binary string that is returned starts like this
( <Image pdf=\"JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0 ............ ) (attached the full xml )

I am wondering what is the best way to create this pdf file. We also use a tool (PDF4NET) that can accept streams to generate the pdf files.. But not sure the following methods to play with the returned xml..

Thank you

Response2.txt
0
Comment
Question by:beos1907
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
Marcjev earned 500 total points
ID: 21859710
The data is base64 encoded. You should make a string of it and pass it thrue Convert.FromBase64String. (see that " is NOT part of the data at start and end!)
See my sample and result file. The actual data is replaced by ... to keep it smaller..
The resulting file is attached.
string pdf = "JVBE...Rgo=";
byte[] outArray = new byte[60000];
outArray = Convert.FromBase64String(pdf);
System.IO.FileStream sw;
sw = new System.IO.FileStream (@"c:\temp\een.pdf",System.IO.FileMode.CreateNew);
 
for (int i = 0; i < outArray.Length; i++)
   sw.WriteByte(outArray[i]);
sw.Close();

Open in new window

een.pdf
0
 

Author Closing Comment

by:beos1907
ID: 31470381
Thank you very much for taking care of this, it worked great..

Is it possible to remove the attached files..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c# DateTime Format validation 4 94
C# XML Get Values 4 54
Stop Git from being my repository 1 51
ComboBox to String Not Working 5 43
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question