Click here to Skip to main content
15,034,432 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Code:

C#
PrinterSettings settings = new PrinterSettings();
    foreach (string printer in PrinterSettings.InstalledPrinters)
    {
        settings.PrinterName = printer;

        if (settings.IsDefaultPrinter)
        {
            strprintname = printer;
        }
    }

    startInfo.FileName = Server.MapPath("download/matrimonimembership.pdf");
           
    startInfo.Verb = "print";
    startInfo.Arguments = strprintname;

    Process proc = new Process();
    proc.StartInfo = startInfo;

    proc.Start();

    proc.WaitForExit(1000);
    if (proc.HasExited == false)
    {
        proc.Kill();
    }


my local system run this code no error. when i host in website not working is code give error.

Get Error is : No application is associated with the specified file for this operation

Please help...........me.
Posted
Updated 5-Jun-13 0:45am
v2
Comments
Prasad Khandekar 5-Jun-13 6:51am
   
Why do you want to print a file on the server, unless of-course your application is an intranet application and server, printer probably located in same building/floor/department.

If it's your internal server then try installing Adobe Acrobat Reader on the sever. It will register the required Print association.
Sunasara Imdadhusen 5-Jun-13 8:55am
   
What does print means? do you want to download file from server in pdf format?
Prasad Khandekar 5-Jun-13 14:29pm
   
Helo Murugan,

Please also see this document from Adobe. (http://www.adobe.com/products/postscript/pdf.html). Since July 2008 PDF is no longer a proprietary format and one good thing about PDF is that it is a file format used to represent documents in a manner independent of application software, hardware, and operating systems and has the same imaging capabilities as PostScript. Having said this now a days many printer manufactures (HP/Ricoh etc.) are coming with printers equipped with true Adobe PostScript Level 2 or Adobe PostScript 3 printing technology. With such printers you can directly print a PDF without going through any application such as Acrobat PDF reader or so.

Regards,

The problem is: even though PDFs are widely used on the Web, this format is not a part of any W3 standards. That said, not all systems and browsers will support showing PDF in the browser at all. (For example, I recently totally exterminated anything related to Acrobat from the systems I use on regular basis, because I think it is disgusting, and now feel much better and view PDFs much faster; I don't suffer from the fact that my alternative product doesn't support any browsers.)

That said, you may need to represent your PDF content in the form of HTML, with some reasonable degree of approximation. Alternatively, you can show PDF preview as image.

To work with PDF, you can use, in particular:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

See also this question and answer: http://stackoverflow.com/questions/2295555/how-to-convert-pdf-into-html-using-c-sharp[^].

—SA
   
If you expect that code to print the pdf at the client printer, then it won't work. Why? because your code is running at server side!!! not at the client machine. it works locally because in your "dev" environment both the client and the server is the same machine ;)
Googling I got the following... HTH

http://stackoverflow.com/q/270674[^]

http://goo.gl/OLPha[^]

http://printinginaspnet6tz.blogspot.com/2012/03/print-pdf-directly-without-preview-from_29.html[^]
   

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