How To view PDF Files in a browser using the filename(path) reference in Database ?

Hi All,

I am working on project where I need to view PDF files in a browser and the file reference (path) of the pdf file is in MS SQL SERVER DB Table.

The table layout is as follows:

Table1                  
autokey      uncname      path      
1      \\servername\sharename      c:\files\0001.pdf      
2      \\servername\sharename      c:\files\0002.pdf      
3      \\servername\sharename      c:\files\0003.pdf      
4      \\servername\sharename      c:\files\0004.pdf      
5      \\servername\sharename      c:\files\0005.pdf      
                  
Table2                  
autokeyid      field1      field2      field2
1                  
2                  
3                  
4                  
5                  

I need to load the 0001.pdf file in the browser and design 3 text boxes so that user can input data into those boxes and that will populate the respective files in table 2.Once that is done user can move onto the next file in the table which is 0002.pdf...and so on

Hope this makes sense.

Can somebody please guide me on this one?

Cheers

Aash.
LVL 8
matrix_aashAsked:
Who is Participating?
 
MogalManicCommented:
sorry, submitted by mistake:
Then in the code behind:
  protected void BuildObjectTag(object sender, EventArgs e)
  {
        string PDFFileLocation="~/PDFS/PDFFile.pdf";
         string ClientPath = page.ResolveClientUrl(PDFFileLoctaion);
         PDFView.Text=string.format(@"<object data='{0}' type='application/pdf' width='300' height='200'>
  alt : <a href='{0}'>Link to {0}</a>
</object>", ClientPath);
  }

NOTE:  The PDF MUST be located within the WEB directory subtree.  If the PDF cannnot be located within the WEB subtree then you need to create a ViewPDF.aspx and the PDFFileLocation would be something like this:
   string PDFFileLocation="~/ViewPDF.aspx?FileName=PDFFile.pdf";
ViewPDF.aspx would then read the PDF file and write it to the Response and set the content type to 'application/pdf'
0
 
Jai STech ArchCommented:
either you have to use FRAMES or open the PDF file separately...

keep your TEXT boxes in one frame and in teh second frame have the PDF displayed...
it is not possible to display the PDF and you controls in one single page without using frames...

opt#2
have your textboxes and the link to hte pdf file in you web page...and when the user clicks the link the pdf can be opened up...
0
 
matrix_aashAuthor Commented:
I want the pdf file and the text boxes on the same page and not separately as it defeats the object. How can i load the image from database, that is the bit which i am confused about. It is possible for you give me some code ?
0
 
MogalManicCommented:
If you want the PDF to be viewed along with other parts of the page, you MUST use one of the following tags:
   <frame>
   <iframe>
   <object>
   <embed>

The object tag would look something like this:
<object data="data/test.pdf" type="application/pdf" width="300" height="200">
  alt : <a href="data/test.pdf">test.pdf</a>
</object>

But, there is a problem.   Since the object tag was used in classic ASP to load COM objects, you cannot do this:
  <object id='PDFObject' runat='server'...>
This is because the ASP processor would try to load the COM object on the server and not generate any client html.

Instead, use the <asp:Literal> control like this:
  <asp:Literal id='PDFView' runat='server OnPreRender="BuildObjectTag"' />

Then in the code behind:
  protected void BuildObjectTag(object sender, EventArgs e)
  {

  }
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.