Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi guys,

i have a pdf file thats gets created by an activex control.
it is then saved to the local machine c:\temp.pdf.

how would i display this in an iframe for user to view.
i have tried this, but when i run the web page it foes not find the file.

Dim buffer As [Byte]() = client.DownloadData("c:\temp.pdf")
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
Response.Flush()
Response.End()


any ideas?

thanks
Anoop
Posted
Comments
Anoop Brijmohun 27-Sep-12 4:24am    
Hi,

i tried this but it requires me to copy to a folder on server first.

Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Dim FilePath As String = Server.MapPath("~/temp/temp.pdf")
Me.lblerror.Text = FilePath
Response.WriteFile(FilePath)
Response.Flush()
Response.End()

it works,
will use this until i can get the above to work.

thanks

1 solution

When you say 'local machine' I assume you mean the 'client side'.
If this is the case you can try using "file:///C:/temp.pdf" in the iframe src. It will depend on the browser/plugin/settings if this will work or not, since the file:/// prefix tends to throw security warnings for some people.

You can quickly read up on it here: http://en.wikipedia.org/wiki/File_URI_scheme[^]

If this does not help in your situation, it might be best to generate the pdf server side and then show it in the iframe using a normal http(s) url.

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900