cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Crystal reports Alignment

Former Member
0 Kudos

Hi,

I am facing some alignment problem after upgraded my report from Crystal X1 R2 to Crystal Runtime(SP2 also SP7)

Initially I designed my report in Crystal X1 R2 to print the report in the pre-designed template. Later I upgraded my application to latest crystal Runtime. After that I am facing some alignment problem when print the report.

After up-gradation, i could see some lines are pushed down and few lines are pushed up and it is not printing properly in the pre-designed template.

I tried to do changes in the designer but it is not printing properly.

I have designed report with zero Page Margins and Paper size is A4.

I can see the correct alignment when printing it directly from Crystal designer But When i print the report pro-grammatically through crystal run-time i am facing the same alignment problem.

When analysing this, I noticed few things.

* Only I am facing the problem with zero margin

* After run time-upgradation, When previewing the report I found additional option in the Print dialog of latest crystal viewer. It is page scaling option and It is defaulted with "Scale report page to fit printer page" and disabled.

* We can export the report to various formats. In that case it is working fine for pdf or woreport document when the page scaling option is set as "Do not scale".

Please find the peace of sample code to print the report (Using sample C# application)

private void Print(object sender, EventArgs e)

{

           ISCDReportClientDocument rptClientDoc;

            PrintOutputController printout;

            PrintReportOptions rasprint = new PrintReportOptions();

            CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(@"C:\Users\Desktop\Sampleprintout\sample.rpt"); //design simple report with various page margins

            rptClientDoc = report.ReportClientDocument;

            printout = rptClientDoc.PrintOutputController;

            rasprint.PrinterName = "HP LaserJet 2200 Series PS";

           printout.PrintReport(rasprint);

           

}

Note: Need to add necessary reference files from "C:\Windows\assembly".

I am still struggling to fix this one.

Please help me out.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Try searching, I've posted some sample app's on how to manage printing.

Note: DO NOT ADD CR ASSEMBLIES FROM THE ASSEMBLY FOLDER. Use the .NET tab on the Add References UI form.

Open the report and click print in CR Designer and uncheck the Center the Page and save the report will help also:

Don

Former Member
0 Kudos

Hi Don,

Thanks for your response.

But In crystal designer, "Center the page" option is dimmed as mentioned below.

And I don't find few references are in .NET, so I added it from "C:\windows\Assembly".

Former Member
0 Kudos

Don,

I would like to add few more points here.

1. In crystal designer, Page scaling option set as "Do not scale". But in Crystal report viewer, It is always defaulted and dimmed as "Scale the report page to fit to printer page".

I tried to modify it manually and pro-grammatically as well. But I could not change that option

2. Only I am facing this alignment problem, when the page margin is set as zero. Otherwise it is working properly.

Thanks.

0 Kudos

Interesting. I asked DEV to explain under what conditions those options are grayed out.

Thanks

Don

Former Member
0 Kudos

Thanks Don. It could be really helpful if you find something about this.

Because we are struggling with this issue past few days.

Also I found the similar kind of issue in many forums. But unfortunately I don't find the solution for that.

0 Kudos

Dev came back and explained that if you set the paper size to larger than what the report was designed against then those options will be enabled. So it's not this causing the problem.

It's likely the printer driver, try a different printer if you can and/or update to the latest driver that supports .NET Framework.

It's odd that if the margins are not zero this works... may be you work around. Some printers do not allow zero margins.

Don

Former Member
0 Kudos

Don,

I have tried with all the options. But always that option was disabled only.

Few clarifications:

1. If there is problem with printer driver, then how it is working properly for other formats like (PDF, MS-word, and also from Crystal designer?). It should not work for other formats also with  zero margins if problem with printer driver?

2. With Crystal X1 R2 it was working fine. Why it is not working for Latest crystal run-time alone?)

3. As I mentioned in the previous thread, always scaling option set as "Scale report page to Fit to printer page" and disabled. Is there any option to change it to "Do not scale".

4. Through Crystal API's. I have tried to create sample application. When I trace the code,

"ReportOptions..PrintOptions.DissociatePageSizeAndPrinterPaperSize" always set as true. Even though I manually set it as "false" it is not taking the value. Always it is true only. when I check "DissociatePageSizeAndPrinterPaperSize" in designer , I am getting same alignment issue in Crystal designer also. (Note: Directly printing from Crystal designer is working with proper alignment)

5. I am using HP printer. How to find printer driver with .Net Framework support with the same?

6. I Installed Crystal X1 R2 designer with different environment.

* Crystal X1 R2 with .NET environment 

* Crystal X1 R2 Without .Net Environment

* crystal X1 R2 in Windows Server 2012(By default enabled with .Net environments)

Without .Net environment I couldn't get alignment issue. If i set page margin as zero then it accepts.

But with .Net environment if i set page margins as zero, in designer itself its not accepting.  If zero margins set then it is showing "top=0.166,bottom=0.18,left=0.166,right=0.18".

whether the problem with .Net? If so how could be it resolved?

Thanks.

0 Kudos

Try this attached app, I know this works correctly.

So forget that the option to scale is grayed out, it's not required.

Former Member
0 Kudos

Hi Don,

I tried with the above application also. But It is showing zero margins only when we display using crystal API's. But still the alignment is not proper.

Please follow the below steps to replicate the issue.

1. Create any sample report with zero margin.

2. Preview it from crystal designer and print directly from the same.

3. Now load your report using the above application

4. Margins are displaying still zero, But you print the report from your sample application

5. Compare both the reports. You can definitely find the alignment difference.

the same u can try with other than zero margins. (But margin value should be greater than 0.166). With other than zero page margin (both the reports taken from crystal designer and crystal viewer will be the same).

I believe this issue is occurring only after upgraded crystal reports to .Net.

Please guide me to solve this issue.

Thanks,

Andrew

0 Kudos

Hi Gallen,

Ah, now that you noted the .166 I just remembered, I think this is by design. As you noted the min margins can be is .166. But I don't recall the reason why now. I think it has something to do with the default printer and the windows.system.printer properties... or framework conversion of the DEVMODE structure into the System Printer structure by Microsoft...

I have to dig some more into the history... I know I have a thread with R&D about this...

For now though you are correct, set the minimum to .166 and work with that until I can find out more about it.

Thanks

Don

0 Kudos

I found it....

CR designer is added minimal margins logic in SP4, but CR.NET does not have this function. Winform SDK will call CR.NET which the printing method uses "PrintToPrinter".

This will be the Kbase on this issue:

1563479 - Page Scaling issue when printing from the .NET Winform
Application

Link won't work, search for it.

But I have workaround below.

CR designer version SP4 or later will be turn on minimal margins function with register key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Crystal Reports\DesignerOptions]
"DealWithMinimalMarginsWhenPrinting"="1"
1.When dissociate formatting page size and printer paper size is checked:
"Reg key =1" or "no" key, keep large marings.
"Reg key = 0", turn on minimal margins printing.
2.when dissociate formatting page size and printer paper size is unchecked:
The reg key doesn't take effect. Always print minimal margins.
************************************************************************************************
We can provide workaround here:
1.Replace the printing method with CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument.PrintOutputController.PrintReport which is from RAS.NET. This method will be "always" controlled by reg key "DealWithMinimalMarginsWhenPrinting":
"Reg key =1" or "no" key, keep large marings.
"Reg key = 0", turn on minimal margins printing.

Limitation and tips of RAS.NET printing method:
<1> PrintOptions.DissociatePageSizeAndPrinterPaperSize will not take effect bucause "PrintReport" will not refresh the report format while printing.
<2> printReportOptions.AddPrinterPageRange("from page number", "to page number") can set printing range.
<3> printReportOptions.PrinterName is to set printer name.
<4> if user want to refresh report to match physical printer setting, please use CR.designer to format it firstly, then use "PrintReport" to print.

2.Use original method "PrintToPrinter" from CR.NET if user don't need print A4 with minimal margins.

I'll kbase this info now also....

Bottom line is you need to create a registry key and use POC to do the printing or update the reports knowing .166 is the default margin when using P2P.

UPDATE: for CR for VS use this registry key and 64 bit OS:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DesignerOptions

For 32 bit OS remove \wow6432Node, it doesn't exist on 32 bit OS's.

Thanks again

Don

Former Member
0 Kudos

Don,

Thanks much for your input.

The above registry logic is working fine. But We have to add "DealWithMinimalMarginsWhenPrinting" = 0 in the below path and the registry area what u have mentioned is not working.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\DesignerOptions

It doesn't required any code change as u mentioned like above. The above registry alone working fine.

After made this changes in registry I can print the data as Crystal designer prints.

Thanks.

Answers (0)