Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Friday, March 23, 2012

Read Image Data From SQL Server

Here is my task I am storing pdf's in sql server. I would like to retrieve the binary data from sql server and write the pdf content into an existing aspx page to the appropriate pageview section. What is the best way to handle this. The code works below but it loads a new browser with the content. I need it to appear in it's tabbed section in the original aspx file. Any assistance you can give me would be greatly appreciated.

Thanks Jerry

oSQLConn.Open()

Dim myreaderAs SqlDataReader

myreader = myCommand.ExecuteReader

Response.Expires = 0

Response.Buffer =True

Response.Clear()

DoWhile (myreader.Read())

Response.ContentType = ("application/pdf")

Response.BinaryWrite(myreader.Item("img_content"))

Loop

Hi,

From your description, it seems that you are going to retrieve the PDF data in tabbed section of the current aspx file, right?

Well, in your scenario, I noticed that you are going to reset the content type to "application/pdf", but the aspx page's content type is "text/html", they cannot be displayed at the same page.

I guess you have comment the "Response.contenttype.." line, right? And you are using Resposne. Binary Write to write the specified information to the current HTTP output. I suggest that you can have a try to wrap all these codes into a user control, use this control in your tabbed section of your current aspx page and try to see if it can work.

Thanks.

|||

Thanks for your response. Maybe this description will help more. I havea tab control on an aspx form. Each tab needs to display the picture, pdf etc etc associated with that particular tab for a specific user. The binary data is stored in a sql server 2005 image field. What would be the best way to achieve the desired result. What would be a good way to handle this? I should also add there may be more then one pdf/image for a particular section.

Thanks

Jerry

|||

Hi,

Well, you can add a Image control in your Tab control container, and create a page which works for displaying the image data from database.

The code snippet on that page to show the image data: (ShowImg.aspx)

// myRead is a DataReader object.
Byte[] Buffer = (Byte[])myRead[0];

//Output
this.Response.Clear();
this.Response.BinaryWrite(Buffer);
this.Response.End();

And then, assign the ImageUrl property of the Image control.

this.Image1.ImageUrl = "showimg.aspx"

Of course, if you want to show different pictures based on the parameters like following:

this.Image1.ImageUrl = "showimg.aspx?imageid=123"

Then, you can receive the parameter on ShowImg.aspx, make a query with that parameter against the database and return the corresponding image data.

Thanks.

Friday, March 9, 2012

RDL Generation

Does anyone know of projects in development to create RDL files from HTML
and/or PDF files? I have to think that if Microsoft has created a render
from RDL to PDF that the reverse would be fairly simple to complete as well.I doubt there is such a thing currently...I certainly haven't seen it
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
(Please respond only to the newsgroup.)
I support the Professional Association for SQL Server ( PASS) and it's
community of SQL Professionals.
"rbowlin" <rbowlin@.discussions.microsoft.com> wrote in message
news:D9FFCD4B-845B-42DD-895D-7815E5E0828F@.microsoft.com...
> Does anyone know of projects in development to create RDL files from HTML
> and/or PDF files? I have to think that if Microsoft has created a render
> from RDL to PDF that the reverse would be fairly simple to complete as
> well.|||There is a *huge* difference in going from RDL to <format> versus <format>
to RDL. RDL is a data-driven template for producing a report, and is far
more succinct. Any <format> is the marriage of a template and a specific
set of data.
Reverse engineering an instance of a report into its template would require
a lot of pattern recognition. Some repeating groups like headings and such
could be easily determined, but depending on the flexibility of the source
report generator, some of the other patterns could be a bear to parse.
Also, depending on the set of data used to generate a report instance, you
may not get complete fidelity in the template generation as the data set may
not exercise all of the possible scenarios.
Teaching software to parse <format> would not be impossible, but it would be
difficult and would likely capture less than the full template in the end.
A better shot would be to convert a known product's template to RDL.
Hitachi Consulting (not my firm) has engagement software that takes Crystal
Reports and produces RDL, for example.
Cheers, Mark
"rbowlin" <rbowlin@.discussions.microsoft.com> wrote in message
news:D9FFCD4B-845B-42DD-895D-7815E5E0828F@.microsoft.com...
> Does anyone know of projects in development to create RDL files from HTML
> and/or PDF files? I have to think that if Microsoft has created a render
> from RDL to PDF that the reverse would be fairly simple to complete as
> well.