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

Discussion in 'ASP .Net' started by AP No spam, Jul 22, 2004.

  1. AP  No spam

    AP No spam Guest

    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.NoCache);
    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
     
    AP No spam, Jul 22, 2004
    #1
    1. Advertising

  2. AP  No spam

    bruce barker Guest

    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" <> wrote in message
    news:...
    > 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.NoCache);
    > 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
     
    bruce barker, Jul 22, 2004
    #2
    1. Advertising

  3. AP  No spam

    Raterus Guest

    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" <> wrote in message news:...
    > 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.NoCache);
    > 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
     
    Raterus, Jul 22, 2004
    #3
  4. AP  No spam

    jojujohnc

    Joined:
    Oct 16, 2006
    Messages:
    1
    is there any way to get print window to gif or bmp

    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.
     
    jojujohnc, Oct 16, 2006
    #4
  5. AP  No spam

    kaverao

    Joined:
    Sep 17, 2009
    Messages:
    3
    Print Pdf directly (without preview) from client side (using asp.net) - Any success?

    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.
     
    kaverao, Feb 11, 2010
    #5
  6. AP  No spam

    ronynaidu84

    Joined:
    Oct 6, 2011
    Messages:
    1
    Process proc = new Process();
    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();
     
    ronynaidu84, Oct 6, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. aa
    Replies:
    6
    Views:
    431
    Jeff @ Dart
    Mar 8, 2005
  2. =?Utf-8?B?cGJi?=

    Crystal Reports Print Without Preview in ASP.NET

    =?Utf-8?B?cGJi?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,064
    =?Utf-8?B?cGJi?=
    Aug 9, 2005
  3. Replies:
    2
    Views:
    491
  4. Replies:
    0
    Views:
    1,032
  5. keto
    Replies:
    0
    Views:
    1,043
Loading...

Share This Page