Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Print Pdf directly (without preview) from client side (using asp.net)

Reply
Thread Tools

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

 
 
AP No spam
Guest
Posts: n/a
 
      07-22-2004
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
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-22-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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



 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      07-22-2004
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) 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

 
Reply With Quote
 
jojujohnc jojujohnc is offline
Junior Member
Join Date: Oct 2006
Posts: 1
 
      10-16-2006
Hello experts,

I am very new to this forum.

I am trying to save the content of a window/frame as gif/bmp. I want to save it either at client side or at server side.

Is there any way to do the same using javascript?

Thank You,
Joju.
 
Reply With Quote
 
kaverao kaverao is offline
Junior Member
Join Date: Sep 2009
Posts: 3
 
      02-11-2010
Hi, Did anybody find the solution for this?

Raterus, i looked at and tried the solution provided by you. However, could not succeed. Can you pls explain little more in detail. mentioning what code segment goes in Codebehind and what js should be placed in designer?
I am using .net3.5, visual studio 2008.

Please help, it's very urgent. Thanks in advance.
 
Reply With Quote
 
ronynaidu84 ronynaidu84 is offline
Junior Member
Join Date: Oct 2011
Posts: 1
 
      10-06-2011
Process proc = newProcess();
proc.StartInfo.WindowStyle =
ProcessWindowStyle.Hidden;
proc.StartInfo.Verb =
"print";
string filePath = Server.MapPath(@"~/" + id + "test.pdf");
proc.StartInfo.FileName =
@"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe";
proc.StartInfo.Arguments =
@"/p /h " + filePath;
proc.StartInfo.UseShellExecute =
false;
proc.StartInfo.CreateNoWindow =
true;
proc.Start();
proc.StartInfo.WindowStyle =
ProcessWindowStyle.Hidden;
if (proc.HasExited == false)
{
proc.WaitForExit(10000);
//proc.Kill();
}
proc.EnableRaisingEvents =
true;
// AcroRd32.exe
proc.CloseMainWindow();
proc.Close();
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to print pdf file directly to printer pavan Java 3 11-05-2008 12:57 AM
How to print pdf file directly to printer =?iso-8859-1?q?Ricardo_R=EDos?= Java 17 08-17-2007 10:16 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM
Preview image directly on PC, save directly to HD Patrick M. Digital Photography 3 01-07-2004 08:29 PM



Advertisments