Hi All,
We got a scenario where we need to print reports in a form having size 7.5X3.5 (where width is 7.5 and height is 3.5). But whenever we are trying to change the size of reports to (7.5 X 3.5) , it automatically changed to landscape mode which is giving wrong result.
After a research, I tried these steps to solve this issue, but did not get success.
- Created the custom paper size in printer.
- Saved report with the same custom size.
- Coded to get the id of custom size form and assigned to the PaperSize property. ( Code is mentioned below)
After following the above steps, Reports are printing fine in first page, but after each print, some pages are skipping for next print i.e. we are not able to print reports in continuous pages.
Please suggest me, how to resolve this issue. (To make more clear I have put) Please find the code as below :-
Dim sTemplateName AsString = "C:\Shanti\SmallForm.rpt"
Dim m_oReportDocument AsNew ReportDocument
m_oReportDocument.Load(sTemplateName)
Dim oPrinterSettings AsNew System.Drawing.Printing.PrinterSettings
Dim doctoprint AsNew System.Drawing.Printing.PrintDocument
doctoprint.PrinterSettings.PrinterName = oPrinterSettings.PrinterName ' Example :- "\\10.248.4.140\EPSON LQ-2090 ESC/P 2 Ver 2.0(Test)"
m_oReportDocument.PrintOptions.PrinterName = oPrinterSettings.PrinterName
m_oReportDocument.PrintOptions.DissociatePageSizeAndPrinterPaperSize = True
For i AsInteger = 1 To doctoprint.PrinterSettings.PaperSizes.Count() - 1
If doctoprint.PrinterSettings.PaperSizes(i).Kind = Drawing.Printing.PaperKind.Custom And oPrinterSettings.PaperSizes(i).PaperName.ToUpper.Trim = "SMALL_7.5X3.5".ToUpper().Trim Then
Dim rawKind AsInteger
rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i)))
m_oReportDocument.PrintOptions.PaperSize = CType(rawKind, PaperSize)
EndIf
Next
m_oReportDocument.PrintToPrinter(0, False, 0, 0)
Note :-
- Report is printing fine from Crystal Report designer.
- We are using Crystal Report 2011 for Designing.
- We are using Crystal report 2008 SP3 as run time.
- We are using VB.Net 2010 for coding.
- Microsoft 2003 and Microsoft 2008 server.
- We are using “EPSON LQ-2090 ESC/P 2 Ver 2.0” dot matrix Printer.
From SAP forum, I got to know that there is an issue in printing custom size paper in Crystal Report, since 2010. But don’t know it has been resolved or not. And if it has been resolved then what will the fix. Please help me in this.
Thank you
Regards,
Shanti