Programmatically set Custom Paper Size for Crystal Report

前端 未结 2 1898
有刺的猬
有刺的猬 2020-12-21 20:58

I have created custom paper Size \"SUPP 15 x 14\" in Setting - Printers - File - Server Properties. Now I’m trying to set custom Paper Size for Crystal Report u

相关标签:
2条回答
  • 2020-12-21 21:47

    This Method works with an Epson LX-300+ ii Dot-Matrix Printer and later models

    If you are using a Printer especially for Printing Receipts here are the steps on how to set your printer for desired paper size

    First Set up Printer to be used: Go to Devices and Printers in Printers select the Printer you are going to use and click - right click Printer Properties Click Preferences... Button. Under Main Tab - Change Document Size to User Defined a new New Window will appear. in Paper Size Name specify the name (i.e. OR Paper) and change paper width and height as desired Click Save then OK

    then set your printer by Pressing right click then set as Default Printer

    Add these line of code for your printing. You can still use parameters and datasets.

    Dim c As Integer
        Dim doctoprint As New System.Drawing.Printing.PrintDocument()
        doctoprint.PrinterSettings.PrinterName = "EPSON L1300 Series"
        Dim rawKind As Integer
        For c = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1
            If doctoprint.PrinterSettings.PaperSizes(c).PaperName = "OR Receipts" Then
                rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(c).GetType().GetField("kind", Reflection.BindingFlags.Instance Or 
    
    Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(c)))
                Exit For
            End If
        Next
    
        Report1.PrintOptions.PaperSize = CType(rawKind, CrystalDecisions.Shared.PaperSize)
        frmPreview.CrystalReportViewer1.ReportSource = Report1
        Report1.PrintToPrinter(1, False, 1, 1)
    
    0 讨论(0)
  • 2020-12-21 21:49

    you can do as this

    var rep = new YursCrystalReport();
    var printerSettings = new System.Drawing.Printing.PrinterSettings();
    var pSettings = new System.Drawing.Printing.PageSettings(printerSettings); 
    pSettings.PaperSize = new System.Drawing.Printing.PaperSize("newsize", 3000, 3000);//custom size  hundredths (100=1 inch)
    pSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
    rep.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;
    rep.PrintOptions.CopyFrom(printerSettings, pSettings);
    
    0 讨论(0)
提交回复
热议问题