Print Crystal Report in asp.net

S

Santosh

Hii..

i am printing crystal reports in asp.net for that purpose i am using
PrintTo Printer method but for that it is needed me to pass printer
name which is installed on my local computer but when i upload it on
server then it gives me an error no default printer . for printing
purpose their is another method in java script window.print() but it
print whole window which includes report toolbar and other buttons but
i want to print only report document.can any one tell me what i can do?
here is the code i am using.


objVillageCryReport.PrintOptions.PaperSource=CrystalDecisions.Shared.PaperSource.Auto;
switch(paperSize_DropDownList.SelectedValue)
{
case "PaperA4" :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA4;
break;
case "PaperA4Small":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA4Small;
break;
case "PaperA3" :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA3;
break;
case "PaperB4":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperB4;
break;
case "PaperB5":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperB5;
break;
case "Paper10x14":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.Paper10x14;
break;
case "Paper11x17":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.Paper11x17;
break;
default :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
break;

}
if(portrait_RadioButton.Checked==true)
{
objVillageCryReport.PrintOptions.PaperOrientation=
CrystalDecisions.Shared.PaperOrientation.Landscape;

}
if(Landscape_RadioButton.Checked==true)
{
objVillageCryReport.PrintOptions.PaperOrientation=
CrystalDecisions.Shared.PaperOrientation.Landscape;
}

objVillageCryReport.PrintOptions.PrinterName="Samsung ML-1610 Series"
//printer installed on my local PC;
if(yes_CheckBox.Checked==true)
{
yes_CheckBox.Text="true";

}
else
{
yes_CheckBox.Text="false";
}
objVillageCryReport.PrintToPrinter(Convert.ToInt32(noOfCopies_TextBox.Text.Trim()),
Convert.ToBoolean(yes_CheckBox.Text)
,Convert.ToInt32(startingPage_TextBox.Text.Trim()),Convert.ToInt32(endPage_TextBox.Text.ToString()));


any help greatly appriciated.
 
R

Rad [Visual C# MVP]

Hii..

i am printing crystal reports in asp.net for that purpose i am using
PrintTo Printer method but for that it is needed me to pass printer
name which is installed on my local computer but when i upload it on
server then it gives me an error no default printer . for printing
purpose their is another method in java script window.print() but it
print whole window which includes report toolbar and other buttons but
i want to print only report document.can any one tell me what i can do?
here is the code i am using.

objVillageCryReport.PrintOptions.PaperSource=CrystalDecisions.Shared.PaperSource.Auto;
switch(paperSize_DropDownList.SelectedValue)
{
case "PaperA4" :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA4;
break;
case "PaperA4Small":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA4Small;
break;
case "PaperA3" :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperA3;
break;
case "PaperB4":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperB4;
break;
case "PaperB5":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.PaperB5;
break;
case "Paper10x14":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.Paper10x14;
break;
case "Paper11x17":
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.Paper11x17;
break;
default :
objVillageCryReport.PrintOptions.PaperSize=CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
break;

}
if(portrait_RadioButton.Checked==true)
{
objVillageCryReport.PrintOptions.PaperOrientation=
CrystalDecisions.Shared.PaperOrientation.Landscape;

}
if(Landscape_RadioButton.Checked==true)
{
objVillageCryReport.PrintOptions.PaperOrientation=
CrystalDecisions.Shared.PaperOrientation.Landscape;
}

objVillageCryReport.PrintOptions.PrinterName="Samsung ML-1610 Series"
//printer installed on my local PC;
if(yes_CheckBox.Checked==true)
{
yes_CheckBox.Text="true";

}
else
{
yes_CheckBox.Text="false";
}
objVillageCryReport.PrintToPrinter(Convert.ToInt32(noOfCopies_TextBox.Text.Trim()),
Convert.ToBoolean(yes_CheckBox.Text)
,Convert.ToInt32(startingPage_TextBox.Text.Trim()),Convert.ToInt32(endPage_TextBox.Text.ToString()));

any help greatly appriciated.

The problem is that the default account asp.net uses does not have access
to printers. You'll need to impersonate an account that does. Create an
account, log in with it, add a printer and then use impersonation for
asp.net to run under the account you have created
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top