Printing Crystal Report on Client Side in ASP.NET C#
I created an ASP.NET application where I print a Crystal Report report. The problem is that the report is printed at the Server Printer, and as it is a Web Application I need it to get printed at the client machine.
I am using the method PrintToPrinter(1, false, 0, 0)
in order to print it without a crystal report viewer.
Does anybody knows if there is a way to have it printed on the client side? If not; what do you recommend to generate reports on the client side for ASP.Net applications?
c# asp.net printing crystal-reports client-side
add a comment |
I created an ASP.NET application where I print a Crystal Report report. The problem is that the report is printed at the Server Printer, and as it is a Web Application I need it to get printed at the client machine.
I am using the method PrintToPrinter(1, false, 0, 0)
in order to print it without a crystal report viewer.
Does anybody knows if there is a way to have it printed on the client side? If not; what do you recommend to generate reports on the client side for ASP.Net applications?
c# asp.net printing crystal-reports client-side
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40
add a comment |
I created an ASP.NET application where I print a Crystal Report report. The problem is that the report is printed at the Server Printer, and as it is a Web Application I need it to get printed at the client machine.
I am using the method PrintToPrinter(1, false, 0, 0)
in order to print it without a crystal report viewer.
Does anybody knows if there is a way to have it printed on the client side? If not; what do you recommend to generate reports on the client side for ASP.Net applications?
c# asp.net printing crystal-reports client-side
I created an ASP.NET application where I print a Crystal Report report. The problem is that the report is printed at the Server Printer, and as it is a Web Application I need it to get printed at the client machine.
I am using the method PrintToPrinter(1, false, 0, 0)
in order to print it without a crystal report viewer.
Does anybody knows if there is a way to have it printed on the client side? If not; what do you recommend to generate reports on the client side for ASP.Net applications?
c# asp.net printing crystal-reports client-side
c# asp.net printing crystal-reports client-side
edited Mar 1 '12 at 21:23
Amen Ayach
3,64011721
3,64011721
asked Mar 1 '12 at 19:04
Francisco GFrancisco G
7842918
7842918
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40
add a comment |
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40
add a comment |
3 Answers
3
active
oldest
votes
Best way is to design a "HTML printable version" of your page with a link calling :
javascript:window.print();
add a comment |
here is what you will need to do / try to get the report to print on the Client Machine
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
add a comment |
The Crystal report viewer is a server side control, and it doesn't really provide an easy way to print to client. I have been able to achieve this in the past by exporting the report to PDF, then with a combination of an embedded PDF viewer and some JavaScript, print the PDF.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string pdfName = String.Format(@"{0}{1}{2}.pdf", pdfPath, reportName, imageGuid);
// expport to unique filename
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdfName);
// Display the pdf object in a literal control (mine's called pdfLiteral)
sb.AppendFormat("<object ID="pdfObject" type="application/pdf" data="{0}" src="{0}" style="width: 2px; height: 2px; ", pdfName);
sb.AppendLine("z-index:1; display: block; top: 0; left: 0; position: absolute; ">");
sb.Append("</object>");
pdfLiteral.Text = sb.ToString();
pdfLiteral.Visible = true;
// client side
// on document load call the printWithDialog function
var code = function(){
var pdf = document.getElementById('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
};
// window onload, with delay
window.setTimeout(code, 1000);
See: https://stackoverflow.com/a/25994086/474702
Note: although this works well in Chrome, it only works in IE if the client has Acrobat reader installed as the default PDF viewer.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9522314%2fprinting-crystal-report-on-client-side-in-asp-net-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Best way is to design a "HTML printable version" of your page with a link calling :
javascript:window.print();
add a comment |
Best way is to design a "HTML printable version" of your page with a link calling :
javascript:window.print();
add a comment |
Best way is to design a "HTML printable version" of your page with a link calling :
javascript:window.print();
Best way is to design a "HTML printable version" of your page with a link calling :
javascript:window.print();
answered Mar 1 '12 at 19:14
Amen AyachAmen Ayach
3,64011721
3,64011721
add a comment |
add a comment |
here is what you will need to do / try to get the report to print on the Client Machine
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
add a comment |
here is what you will need to do / try to get the report to print on the Client Machine
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
add a comment |
here is what you will need to do / try to get the report to print on the Client Machine
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
here is what you will need to do / try to get the report to print on the Client Machine
Below line opens up print dialog box to print without showing print preview
crystalReportViewer1.PrintReport();
Below line directly sends reportdocument to default printer.
oReportDocument.PrintToPrinter(1,true,0,0);
answered Mar 1 '12 at 19:16
MethodManMethodMan
15.8k62749
15.8k62749
add a comment |
add a comment |
The Crystal report viewer is a server side control, and it doesn't really provide an easy way to print to client. I have been able to achieve this in the past by exporting the report to PDF, then with a combination of an embedded PDF viewer and some JavaScript, print the PDF.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string pdfName = String.Format(@"{0}{1}{2}.pdf", pdfPath, reportName, imageGuid);
// expport to unique filename
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdfName);
// Display the pdf object in a literal control (mine's called pdfLiteral)
sb.AppendFormat("<object ID="pdfObject" type="application/pdf" data="{0}" src="{0}" style="width: 2px; height: 2px; ", pdfName);
sb.AppendLine("z-index:1; display: block; top: 0; left: 0; position: absolute; ">");
sb.Append("</object>");
pdfLiteral.Text = sb.ToString();
pdfLiteral.Visible = true;
// client side
// on document load call the printWithDialog function
var code = function(){
var pdf = document.getElementById('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
};
// window onload, with delay
window.setTimeout(code, 1000);
See: https://stackoverflow.com/a/25994086/474702
Note: although this works well in Chrome, it only works in IE if the client has Acrobat reader installed as the default PDF viewer.
add a comment |
The Crystal report viewer is a server side control, and it doesn't really provide an easy way to print to client. I have been able to achieve this in the past by exporting the report to PDF, then with a combination of an embedded PDF viewer and some JavaScript, print the PDF.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string pdfName = String.Format(@"{0}{1}{2}.pdf", pdfPath, reportName, imageGuid);
// expport to unique filename
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdfName);
// Display the pdf object in a literal control (mine's called pdfLiteral)
sb.AppendFormat("<object ID="pdfObject" type="application/pdf" data="{0}" src="{0}" style="width: 2px; height: 2px; ", pdfName);
sb.AppendLine("z-index:1; display: block; top: 0; left: 0; position: absolute; ">");
sb.Append("</object>");
pdfLiteral.Text = sb.ToString();
pdfLiteral.Visible = true;
// client side
// on document load call the printWithDialog function
var code = function(){
var pdf = document.getElementById('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
};
// window onload, with delay
window.setTimeout(code, 1000);
See: https://stackoverflow.com/a/25994086/474702
Note: although this works well in Chrome, it only works in IE if the client has Acrobat reader installed as the default PDF viewer.
add a comment |
The Crystal report viewer is a server side control, and it doesn't really provide an easy way to print to client. I have been able to achieve this in the past by exporting the report to PDF, then with a combination of an embedded PDF viewer and some JavaScript, print the PDF.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string pdfName = String.Format(@"{0}{1}{2}.pdf", pdfPath, reportName, imageGuid);
// expport to unique filename
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdfName);
// Display the pdf object in a literal control (mine's called pdfLiteral)
sb.AppendFormat("<object ID="pdfObject" type="application/pdf" data="{0}" src="{0}" style="width: 2px; height: 2px; ", pdfName);
sb.AppendLine("z-index:1; display: block; top: 0; left: 0; position: absolute; ">");
sb.Append("</object>");
pdfLiteral.Text = sb.ToString();
pdfLiteral.Visible = true;
// client side
// on document load call the printWithDialog function
var code = function(){
var pdf = document.getElementById('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
};
// window onload, with delay
window.setTimeout(code, 1000);
See: https://stackoverflow.com/a/25994086/474702
Note: although this works well in Chrome, it only works in IE if the client has Acrobat reader installed as the default PDF viewer.
The Crystal report viewer is a server side control, and it doesn't really provide an easy way to print to client. I have been able to achieve this in the past by exporting the report to PDF, then with a combination of an embedded PDF viewer and some JavaScript, print the PDF.
// On server side
// Export to PDF
Guid imageGuid = Guid.NewGuid();
string pdfName = String.Format(@"{0}{1}{2}.pdf", pdfPath, reportName, imageGuid);
// expport to unique filename
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, pdfName);
// Display the pdf object in a literal control (mine's called pdfLiteral)
sb.AppendFormat("<object ID="pdfObject" type="application/pdf" data="{0}" src="{0}" style="width: 2px; height: 2px; ", pdfName);
sb.AppendLine("z-index:1; display: block; top: 0; left: 0; position: absolute; ">");
sb.Append("</object>");
pdfLiteral.Text = sb.ToString();
pdfLiteral.Visible = true;
// client side
// on document load call the printWithDialog function
var code = function(){
var pdf = document.getElementById('pdfObject');
if (pdf == null)
return;
try {
pdf.printWithDialog();
}
catch (err) {
alert('Please Install Adobe Acrobat reader to use this feature');
}
};
// window onload, with delay
window.setTimeout(code, 1000);
See: https://stackoverflow.com/a/25994086/474702
Note: although this works well in Chrome, it only works in IE if the client has Acrobat reader installed as the default PDF viewer.
edited May 23 '17 at 12:03
Community♦
11
11
answered Apr 18 '17 at 13:11
reckfacereckface
3,37822546
3,37822546
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9522314%2fprinting-crystal-report-on-client-side-in-asp-net-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's been awhile since I did anything with Crystal, but see if it has an option to render the report to a PDF. You can then send that down to the client. It won't automatically print, but they'll be able to without Crystal installed, as long as they have a PDF viewer.
– Matt Sieker
Mar 1 '12 at 19:40