Printing a pdf file on the client side of a printer in asp.net c #?

I have a problem in my project that I open a dynamically generated PDF file in a popup that works correctly. But now I want to print this PDF directly when the popup is open on the client printer, how can I solve it?

I need your help. Please offer me a code for this.

+3
source share
2 answers

Try this code, it will work for you.

    Process printjob = new Process();

    printjob.StartInfo.FileName = @"D:\R&D\Changes to be made.pdf" //path of your file;

    printjob.StartInfo.Verb = "Print";

    printjob.StartInfo.CreateNoWindow = true;

    printjob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

    PrinterSettings setting = new PrinterSettings();

    setting.DefaultPageSettings.Landscape = true;

    printjob.Start();
0
source

You need to open a popup with javascript and run a function on it print().

var opts = 'width=700,height=500,toolbar=0,menubar=0,location=1,status=1,scrollbars=1,resizable=1,left=0,top=0';
var newWindow = window.open(yourUrl,'name',opts);
newWindow.print();

Please note that the URL you open must be in the same domain as your current page to work.

+5
source

All Articles