cancel
Showing results for 
Search instead for 
Did you mean: 

Report does not print exactly same as it appears at design time

Former Member
0 Kudos

Hello,

I am using SAP Crystal report with VS 2010.

I designed a report. At design time every thing appears fine. Margins are set to 0, printer is selected and page size is custom.(right click on report, design>pagesetup)

When I use <reportname>.printtoprinter(), it dramatically changes the text size and margins of the report in hard copy. I tried literally everything for this. Especially It adds nearly 2 inches extra margin at top.Also , at run time it changes the font size to 8 or 9 points if i have set it to 12 at design time.

I get the same problem if I do following:

crystalReportViewer1.ReportSource = rptRcAbh;

crystalReportViewer1.PrintReport();

HOWEVER!!

When I do this:

crystalReportViewer1.ReportSource = rptRcAbh;

AND when I manually click the print button of crystal report viewer, i get EXACTLY SAME result as design time. This is what I am expecting from printoprinter() method. But Its changing result dramatically.

Why is this happening? Am I forgetting any setting?

I must use reprot.printtoprinter() method here. Because I am printing the bill receipt. I dont want the user to go to printpreview then click print. AND I must get same result as design on printed page.

Please help me. I am in urgent need.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Moved your post to .NET SDK forum.

Search here on PrintOutputController and use it to print your report. Requires RAS which you have available. P2P is limited in it's abilities.

Also, If the printer you designed the report originally from is not available CR uses the margins of the default printer, which is why the margins changed.

Other options, check on the No Default Printer, may work for you but be careful with this function. Also check on the Dissociate.. option and save your report. Or you can do it in code also.

One last issue, Microsoft's scales the print out by something like 1.5 %, it's a limitation in the Framework and nothing CR can do about it...

Try searching, lots of info on this subject in this forum.

Don

Former Member
0 Kudos

Hello,

Thanks for contributing, Don.

in report design>page setup:

Already I have checked "No printer" option .

I have already checked "Dissociate.." and i have selected custom page size.

I would happily work if scale would differ by 1.5%. but its reduced nearly by 60%.

All margins are set to 0. still its adding 2 inches margin.

I did not get proper information about PrintOutputController. Will you please post some code?

But most crucial issue is Above problem is occurring only if i use PrintToPrinter(). NOT when I click print button of crystalreportviewer control. It gives perfect output when I use print button of it.

former_member188030
Active Contributor
0 Kudos

Hi,

See if applying [SP2 for CR for VS 2010 |http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_2.exe]helps,

Take a look at the [In Proc RAS .NET SDK for CR for VS 2010 Developer guide|http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/xi4_rassdk_net_dg_en.zip] which will give you more information about the PrintOutputController.

Also search the forum for more information, PrintToPrinter and PrintOutputController has been discussed many times before.

You will definityely find your answers.

- Bhushan

0 Kudos

I use a common dialog box to get and populate the system and user printers


using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.CommonControls;
using CrystalDecisions.ReportAppServer.CommLayer;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.DataSetConversion;
using CrystalDecisions.ReportAppServer.DataDefModel;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Windows.Forms;

        private void btnPrintOutPut_Click(object sender, System.EventArgs e) // Print To P button
		{
			System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();			
			CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
            CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions newOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();

			pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;
            pDoc.PrinterSettings.SupportsColor.ToString();

            if (pDoc.PrinterSettings.SupportsColor)
            {
                MessageBox.Show("Printer Supports Color", pDoc.PrinterSettings.SupportsColor.ToString());
            }

			rasPROpts.PrinterName = cboCurrentPrinters.Text;			
			rasPROpts.PaperSize = (CrPaperSizeEnum) pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind; 
			//rasPROpts.PaperSource = (CrPaperSourceEnum) pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind; 

           		rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
			MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information ); 
		}

Search more, as mentioned lot's of posts on this subject.

Don

Former Member
0 Kudos

Hi Don,

Can you please tell me what is rptClientDoc in the code spinnet you have posted just now? The line is this:

rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

Asking you this because when I instantiated my report , I did not find any properly called PrintOutputController for my object 'rp' in below line:

rptReceiptAbhishek rp = new rptReceiptAbhishek();

Intellisense did not show PrintOutputController property.

I will give a print as soon as you let me know this.

Also, for your information, I am trying to print report on a local machine on winforms application and not in asp.net web application.

Although the code you have entered is not understandable to me for now, I will study it later.

Waiting for your reply.

Thanks.

0 Kudos

Once again if you search you will find all of this info...

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

Don

Former Member
0 Kudos

Hi Don,

Firstly I am very very thankful to you for replying me.

I know I must have irritated you a bit cuz I was expecting everything ready which I should have 😛

but I was in urgent need and there was no time for me to read everything. I must say a thing that I did not get good search results on printcontroller when I used search box of this website.

Well Thanks again for helping me in deed.

I am sure this must be the problem for many people across the globe, hence I am posting the exact code that helped me to print the document Accurately:

rptReceiptAbhishek rptRcAbh = new rptReceiptAbhishek();

// rptRcAbh.Load("rptReceiptAbhishek.rpt", OpenReportMethod.OpenReportByTempCopy); i did't need this line

//////// Directly Entering data to the fields of the report.

CrystalDecisions.CrystalReports.Engine.TextObject txtname;

CrystalDecisions.CrystalReports.Engine.TextObject txtaddress;

txtname = (CrystalDecisions.CrystalReports.Engine.TextObject)rptRcAbh.ReportDefinition.ReportObjects["txtRptName"];

txtname.Text = cboInitials.Text + " " + cboDonarName.Text;

txtaddress = (CrystalDecisions.CrystalReports.Engine.TextObject)rptRcAbh.ReportDefinition.ReportObjects["txtRptAdd"];

txtaddress.Text = txtAddess.Text;

rptRcAbh.PrintOptions.PrinterName = Properties.Settings.Default.PrinterName;

System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();

CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions newOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();

pDoc.PrinterSettings.PrinterName = Properties.Settings.Default.PrinterName;

pDoc.PrinterSettings.SupportsColor.ToString();

//if (pDoc.PrinterSettings.SupportsColor)

//{

// MessageBox.Show("Printer Supports Color", pDoc.PrinterSettings.SupportsColor.ToString());

//}

rasPROpts.PrinterName = Properties.Settings.Default.PrinterName;

// rasPROpts.PaperSize = (CrPaperSizeEnum)pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;

//rasPROpts.PaperSource = (CrPaperSourceEnum) pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind;

// rptReceiptAbhishek rpt = new rptReceiptAbhishek();

var rptClientDoc = rptRcAbh.ReportClientDocument;

rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

MessageBox.Show("Printing in progress. Make sure that printer is not turned off.", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);

Former Member
0 Kudos

Hi Bhushan, Although Your post did not help me in solving my problem, It will help many others to get direct link to download PROPER version of Crystal reports and the reference Guide for which I spent long time even to search proper one.

Hence rewarding you few points.

Thanks a lot.

Answers (0)