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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a pdf file to a label control

Status
Not open for further replies.

BasicBoy

Programmer
Feb 22, 2008
156
ZA
I have a list of articles on a Gridview/Datagrid control. If the client clicks on an article, then I know what the path and filename is - it refers to pdf files on the server application path.

I wish to bring up the pdf file into a preloaded control on the webpage, which I thought should be a label or text box control - I am not sure.

How would I stream the pdf file into such a control - and clear it when the client selects another article/pdf file.

I have previously streamed .txt files into label controls and think one might do the same with pdf files.

Thanks
 
I don't think you can do the same thing you did with text files for .pdfs. Text files are just that, text. pdf files are a proprietary file type. You can stream it to a label or textbox, but all you will see is gibberish. You could check Adobe and see if they have an API you can call that would do that, but I highly doubt it, remember, they want you to use and buy their product.
 
I have now been able to insert an iframe (with html) to do this, but I need to change the filename when somebody clicks on the gridview - so how can I update the link of an iframe?

Thanks
 
you would stream the pdf to the client and set the content type to pdf (instead of html, xml, etc). a generic handler (ashx) is your best option for that. after that is just http. so embed it in a iframe, open a new tab, whatever you want.

for examples on generic handlers google "generic handler display image from database". the principles are the same, the source is different that's all.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
All I really need to know is how I can put a parametric variable in the 'src' field so that I can show a different document each time the gridview is clicked.

<iframe src=" width="100%" height="600" align="right"></iframe>


If anybody can help.

Thanks a lot
 
this can be done on the client using javascript. here is the basic idea. if you need more assistance than the forum216 will be able to assist. Note: in the js forum will not care you are using asp.net or webforms, only what the render html is.
Code:
<script>
   document.getElementById("foo").src = [new location];
</script>
<iframe id="foo" src="..."/>

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top