Printing Crystal Report Using Custom Paper Size RRS feed

  • Question

  • Hi Stefano,

    I hope you get this message and will reply.

    I am also in the same posiotion and have been suffering to get this solution to work since long.

    I have used a solution by Stefano Crosatti (from http://social.msdn.microsoft.com/forums/en-US/vscrystalreports/thread/e16a1630-ad0c-4fda-8351-16e0807072eb/ ) but when my report display's and I check the Printer Preference the paper size still shows Letter. Please see my codes below and let me know if I am doing anything wrong.

    cmd.CommandText = ("SELECT * FROM StockItem")
    cmd.Connection = Con
    DA.SelectCommand = (cmd)
    DA.Fill(DSRpt, cmd.CommandText)
    DTRpt = DSRpt.Tables(0)

    rptDoc = New ReportDocument
    Dim rptPath As String = Application.StartupPath & "\CrystalReceipt.rpt"
    frmRptViewer.Text = "Print Sales Order"
    frmRptViewer.CrystalReportViewer1.ReportSource = rptDoc
    Dim doctoprint As New System.Drawing.Printing.PrintDocument()
    doctoprint.PrinterSettings.PrinterName = "EPSON LQ-300+ /II ESC/P 2" '"EPSON LQ-300+II ESC/P2" '(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 = "A6 LR" Then
          rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(i).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(i)))
          rptDoc.PrintOptions.PaperSize = rawKind
          Exit For
       End If
    rptDoc = Nothing

    Thank you and hope to hear from you soon.

    • Moved by Sheng Jiang 蒋晟 Tuesday, September 4, 2012 5:48 PM Not related to forum engine (From:Suggestions and Feedback for the Forums)
    Monday, August 13, 2012 8:46 AM


  • I think crystal support is over here now.





    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    • Proposed as answer by Santosh Bhandarkar Tuesday, August 14, 2012 1:37 AM
    • Marked as answer by Naomi N Sunday, August 19, 2012 6:56 AM
    • Unmarked as answer by Maksfriends Wednesday, August 22, 2012 6:27 PM
    • Marked as answer by Just Karl Tuesday, September 24, 2013 8:16 PM
    Monday, August 13, 2012 9:44 PM