469,620 Members | 1,857 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,620 developers. It's quick & easy.

Print Crystal Report in asp.net

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=Cryst alDecisions.Shared.PaperSource.Auto;
switch(paperSize_DropDownList.SelectedValue)
{
case "PaperA4" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4;
break;
case "PaperA4Small":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4Small;
break;
case "PaperA3" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA3;
break;
case "PaperB4":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB4;
break;
case "PaperB5":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB5;
break;
case "Paper10x14":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper10x14;
break;
case "Paper11x17":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper11x17;
break;
default :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.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="Sams ung 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.

Dec 26 '06 #1
3 9364
On 26 Dec 2006 06:01:15 -0800, Santosh wrote:
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=Cryst alDecisions.Shared.PaperSource.Auto;
switch(paperSize_DropDownList.SelectedValue)
{
case "PaperA4" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4;
break;
case "PaperA4Small":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4Small;
break;
case "PaperA3" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA3;
break;
case "PaperB4":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB4;
break;
case "PaperB5":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB5;
break;
case "Paper10x14":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper10x14;
break;
case "Paper11x17":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper11x17;
break;
default :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.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="Sams ung 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
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 26 '06 #2
i am not having any idea about how to so all these can u tell me how
would i ?

Rad [Visual C# MVP] wrote:
On 26 Dec 2006 06:01:15 -0800, Santosh wrote:
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=Cryst alDecisions.Shared.PaperSource.Auto;
switch(paperSize_DropDownList.SelectedValue)
{
case "PaperA4" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4;
break;
case "PaperA4Small":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA4Small;
break;
case "PaperA3" :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperA3;
break;
case "PaperB4":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB4;
break;
case "PaperB5":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.PaperB5;
break;
case "Paper10x14":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper10x14;
break;
case "Paper11x17":
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.Shared.PaperSize.Paper11x17;
break;
default :
objVillageCryReport.PrintOptions.PaperSize=Crystal Decisions.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="Sams ung 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
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 29 '06 #3
On 29 Dec 2006 03:19:05 -0800, Santosh wrote:
i am not having any idea about how to so all these can u tell me how
would i ?
Take a look at this;

http://www.codeguru.com/forum/archiv.../t-290238.html

--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Randy | last post: by
4 posts views Thread by Wendy Elizabeth | last post: by
5 posts views Thread by Tony Dong | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.