Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Bytes Sent to Page

Status
Not open for further replies.

Slonoma

Programmer
Jul 10, 2003
41
US
Hi All,
I am trying to retrieve the bytes sent to a page (probably use a BinaryReader). What is the easiest way to do this? I'm assuming there is some property in the Page object in which I can read from - but I don't know where to find it. I am using VS2005 .NET 2.0 C#.

Thanks!
Slo-No

The trouble with programmers is that they get high on their own supply. -Dimandja
 
I am trying to retrieve the bytes sent to a page
What are your reasons for this (i.e. what are you actually trying to do)?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You had to ask.... :)

We have dynamic PDFs being rendered in a page. The user will enter/change data in the PDF fields. When the user clicks the 'Submit' button on the PDF page itself, the PDF is sending itself as a byte array to the specified page.

And that is where I stand - trying to figure out how to read in this byte array so it can be saved to the database/data extracted from the stream, etc.

Easy stuff, huh?

The trouble with programmers is that they get high on their own supply. -Dimandja
 
lol - I wish I hadn't!

So can you actually get a reference to the byte array or is that still where you are having problems?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Once I get a reference to it I should be fine, I have been working with reading and writing these PDFs as BinaryStreams from files and databases(cool stuff, I might add).
So now I just need to know how to reference the byte array being sent to the page.

The trouble with programmers is that they get high on their own supply. -Dimandja
 
I was able to find this object: Request.InputStream.

Thanks for your help guys!

The trouble with programmers is that they get high on their own supply. -Dimandja
 
Thought I should throw the quick and easy code in there, so here you go:

Code:
    protected void Page_Load(object sender, EventArgs e)
    {
        byte[] rawPDF = new byte[Request.InputStream.Length];
        string path = @"C:/testPDF.pdf";
        FileStream textFilestream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);

        using (BinaryReader br = new BinaryReader(Request.InputStream))
        {
            rawPDF = br.ReadBytes((int)Request.InputStream.Length);
            using (BinaryWriter bw = new BinaryWriter(textFilestream))
            {
                bw.Write(rawPDF);
                bw.Close();
            }

            br.Close();
        }

    }

The trouble with programmers is that they get high on their own supply. -Dimandja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top