Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there !

I am using Crystal Reports to print a report directly to the printer. When the report is sent to the printer, it always prints A4 size. Below is the code I'm using:

VB
Dim pd As New PrintDocument()

pd.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize("Reserved48", 280, 3276)
Cmd.Connection = Con
Cmd.CommandTimeout = 0
Cmd.CommandType = CommandType.Text
SQL = " Select * from City "
Cmd.CommandText = SQL
DA.SelectCommand = Cmd
DA.Fill(DS, "Rep")
oReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument
oReport.PrintOptions.CustomPaperSource  =
Dim strSystemName As String = "\\main\"
Dim strPrinterName As String = "EPSONLQ-"
oReport.PrintOptions.PrinterName = strSystemName & strPrinterName
oReport.PrintOptions.PrinterName = printername
Dim doctoprint As New System.Drawing.Printing.PrintDocument()
doctoprint.PrinterSettings.PrinterName = "\\main\" '(ex. "Epson SQ-1170 ESC/P 2")
Dim i As Integer
oReport.Load("d:\Invoice.rpt")

Response.Write(oReport.PrintOptions.PageContentHeight)
Response.Write(oReport.PrintOptions.PageContentWidth)

oReport.Database.Tables(0).SetDataSource(DS.Tables("Rep"))
oReport.PrintOptions.PaperSize = CType(System.Drawing.Printing.PaperKind.Custom, CrystalDecisions.Shared.PaperSize)
oReport.PrintToPrinter(1, False, 0, 0)


The desired size is 3 by 9 inches. Please guide me in this. Thanks in advance!
Posted
Updated 26-Jan-11 11:25am
v3
Comments
Manfred Rudolf Bihy 26-Jan-11 14:51pm    
Added code tags.
Nauman Sarwar 26-Jan-11 15:00pm    
Hi Manfred!

I do not get your answer ?
Manfred Rudolf Bihy 26-Jan-11 15:14pm    
That was not an answer it is called a comment. My comment was purely informational and tells you that I edited your question to add code tags. Using code tags makes program code that you include in your questions (or answers) look neatly formatted with a fixed width font and including syntax highlighting.
Christian Graus 26-Jan-11 15:50pm    
Do you REALLY want your website to print to a physical printer in the server room ?
Nauman Sarwar 26-Jan-11 15:59pm    
Yes i really want that and its locally hosted

1 solution

Already I have answered for this kind of question on last month.

Crystal report change paper size[^]

Also take a look at this one

Crystal report: resizing papersize[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900