469,140 Members | 1,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,140 developers. It's quick & easy.

Print Pdf directly (without preview) from client side (using asp.net)

Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/pdf";
Response.BinaryWrite(memStream.ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javascript">
window.print();
</script>
I tried also with frameset (don't work)
and I tried also

with

<script language="javascript">
var oWnd = window.open("TestPrint.Aspx", "tstPrint");
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".
Can you help me????

Thanks in advance!!!

Bye bye
Nov 18 '05 #1
2 13601
you can not directly print a pdf file in a browser, nor can you include
javascript. when the browser detects a pdf file, it looks an activex control
assigned to the mime type, in this case adobe reader. it then loads adobe
reader active/x control, and gives the control the url. the reader control
then requests and downloads the content (if you have ie 6.0 with service
packs, the download will come from the cache, otherwise the pdf is
downloaded again) and renders it.

-- bruce (sqlwork.com)
"AP No spam" <al******@lycos.it> wrote in message
news:fb**************************@posting.google.c om...
Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/pdf";
Response.BinaryWrite(memStream.ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javascript">
window.print();
</script>
I tried also with frameset (don't work)
and I tried also

with

<script language="javascript">
var oWnd = window.open("TestPrint.Aspx", "tstPrint");
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".
Can you help me????

Thanks in advance!!!

Bye bye

Nov 18 '05 #2
Just tested this, and it works, except the pdf does have to load up in the acrobat plugin, but you do get prompted for the print dialog as well.

<iframe> that holds the pdf, and only the pdf
then from the main page, use this javascript to print the iframe.

<script type="text/javascript">
function pdfPrint(iframe)
{
iframe.focus();
iframe.print();
}

pdfPrint(iframe_id);
</script>

You can use Page.RegisterStartupScript to add this script easily from asp.net.

--Michael
"AP No spam" <al******@lycos.it> wrote in message news:fb**************************@posting.google.c om...
Hi

I need help to Print Pdf File directly
without preview from client side

To solve problem I used

This C# code

Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/pdf";
Response.BinaryWrite(memStream.ToArray());
Response.End();

and how you can see

I Clean response and Use BinaryWrite

so I don't know how to insert this html code

<script language="javascript">
window.print();
</script>


I tried also with frameset (don't work)
and I tried also

with

<script language="javascript">
var oWnd = window.open("TestPrint.Aspx", "tstPrint");
oWnd.print();
</script>

it shows message "file TestPrint.Aspx not found".


Can you help me????

Thanks in advance!!!

Bye bye

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Martin | last post: by
2 posts views Thread by Yuriy | last post: by
6 posts views Thread by CSharpguy | last post: by
9 posts views Thread by igotyourdotnet | last post: by
18 posts views Thread by =?Utf-8?B?SGVyYg==?= | last post: by
3 posts views Thread by =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.