Setting custom paper in crystal report

Oct 25 2007 11:13 PM

I'm doing some letter 2 up repot using visual studio .net 2005 with crystal report.I'm using c# language to do the report.

 I have set the custom paper size with 8.5x5.5 inch in the client pc in the server propertise in the printer section.

 as the report size i'm doing is half page of letter and i can't find the paper name in the papersize collection in the crystal report library file.

 

PrintDocument printDoc = new PrintDocument();

PaperSize pkSize = new PaperSize();

int rawKind = 0;

for (int a = 0; a < printDoc.PrinterSettings.PaperSizes.Count; a++)

{

if (printDoc.PrinterSettings.PaperSizesAngel.PaperName == "8.5x5.5")

{

rawKind = (int)printDoc.PrinterSettings.PaperSizesAngel.GetType().GetField("kind", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(printDoc.PrinterSettings.PaperSizesAngel);

}

}

oRpt.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;

 

i didn't not define the printer name in my souce code. when i run this code, system will get default printer to get the paper size collection to get the custom paper size i want.

when i get the custom paper size ID then i fix the ID in the crystal report.

 

i can ge the correct paper size when i preview the report.

but when i click the print button after preview the report, the printer use letter size to print out the report instead of using the custom size i define.

 

i did do some testing in the client pc. If i set the default paper size to the custom paper name i define in the client pc and the paper source to manual feed paper. when i use dirent printtoprinter. it works fine to print out in half page report.

but if i preview the report and go to print, it will print out in the letter size paper instead of the half page letter size.

 

 

anyone can help me to solve this poblem ??? i'm already headache with this and got no idea on how to solve it .

Please Help me..


Answers (2)