cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default custom page size for crystal report

Former Member
0 Kudos

Hi,

I had created my crystal report(using CR XI R2) on a custom paper size(10cm*4cm). When I view this report on CR viewer, it picks up the correct paper size(the custom paper size that i had used in CR designer). But when i view the same report on a different pc, CR viewer picks up A4 size by default(instead of my custom paper size). Note that I had already created the same custom paper size on the other pc as well and also set it as the default paper size of the printer.Also, the same printers are configured on both pc's.

Although I can resolve this issue by installing CR X1 R2 developer version on the other pc, open that crystal report and set its page size to the custom page size. Then it picks up the correct page size. But this is not a feasible solution for me. I cannot install CR developer version everytime i need to view my custom page size report on some other pc.

I searched regarding this and found the following:

"I can't believe CR is acting in such a (stupid) way!

The fact is that crystal report save the information of the format of a report in a non-portable way!
It saves the "ID" of the format instead of his "Name"!
The problem is that in Windows this ID is machine dependent.

The trick is very simple:

1 - Search on the system for the printer you want to use.

2 - Cycle over all the supported format searching for your custom format (I search it by name but you can search it also by dimensions (in inches)).

3 - Get the ID.

4 - Assign it to the report's PaperSize property.

5 - Bingo!

Here it is a quick example:

            Dim doctoprint As New System.Drawing.Printing.PrintDocument()
            doctoprint.PrinterSettings.PrinterName = "YourPrinterName" '(ex. "Epson SQ-1170 ESC/P 2")
            For i = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1
                Dim rawKind As Integer
                If doctoprint.PrinterSettings.PaperSizes(i).PaperName = "MyCustomFormatName" Then
                    rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i)))
                    oRpt.PrintOptions.PaperSize = rawKind
                    Exit For
                End If
            Next

Hope it helps!

Cheers

Stefano

  • Proposed As Answer by deepgags Thursday, February 26, 2009 9:02 PM"

But the above mentioned solution did not worked for me. Please suggest me some workaround to this limitation of CR to pick up custom page size by default. This is really urgent for me. Any help appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Assuming you are using one of our SDK's

Upgrade to CR XI R2 SP 4 and apply SP6 first to see if that works for you.

https://smpdl.sap-ag.de/~sapidp/012002523100009114712011E/crxir2sp4_fullbuild.exe
https://smpdl.sap-ag.de/~sapidp/012002523100009114412011E/crxir2sp6_incremental.exehttps://smpdl.sap-ag.de/~sapidp/012002523100009114712011E/crxir2sp4_fullbuild.exe<br>https://smpdl.s...

R2 is end of life and support so if that doesn't help then search this forum for more samples on using the printer API's.

Don

Former Member
0 Kudos

Hi Don,

I am using CR XI R2 just for designing the reports. Then I use the designed reports in my application which is referring to the dll's of CR 13. The CR 13 viewer picks up the correct page size on the system where i had designed the report. But on any other system it picks up the 'A4' page size.

Searched a lot regarding this but unable to find any solution. This issue is driving me crazy. Any help appreciated.

0 Kudos

Hi Praveen,

This sounds like a bug I just logged. Quick test, If you print from the viewer and manually select the right paper size does that work?

I wonder if it has anything to do with this MS Kbase?

http://support.microsoft.com/default.aspx?scid=kb;en-us;184291

See if that resolves the issue...

Don

0 Kudos

Hi Praveen,

I have a test app that I use to do all of my printing tests with, it's by no means complete and some steps may be bugging but try this to see if it works for you...

Let me know if using the Print selection and eiter or both PrintToPrinter or PrintOutPutController works.

It's an on going bug with R&D to resolve ALL of the printer issues...

Don

PS I had to rename the file from .zip to .txt so rename it back

Former Member
0 Kudos

Hi Don,

I had managed to resolve this issue. The problem was(as I mentioned earlier) that crystal report saves the 'paper id' with it instead of paper name.

On my local machine the custom paper id was 120 while on other machine it was 122. so i created a couple of more custom paper on my local system, used the custom paper with id=122 with the report and then placed the report on the other system.This time it worked fine because it found the correct paper id.

But really, this is a very big bug with CR. The paper should be searched with paper name(not paper id).

Hopefully this will be resolved in future versions of CR.

Hope this helps anyone facing the same problem

0 Kudos

Hi Praveen,

Great catch... That actually makes more sense because ID's will always change for custom Paper Sizes. Works great for standard sizes because their ENUM's are always the same, or should be.

In CR 2008 we changed the Printer info and API's to add the ability to set Orientation for each section I believe. With this change it altered the Printer info saved in the report.

I'll pass this forum link onto our SDK people and discuss....

Thanks for the info and Business Case.

Don

Answers (0)