VB.net定价自定义PaperSize

时间:2019-03-08 16:01:38

标签: vb.net printing

我对此进行了大量研究。我尝试了几种方法来解决此问题,但是由于某些原因,打印机忽略了指定的纸张尺寸。最后的代码迭代似乎应该可以工作,但是却不能工作,并且可以打印更大的纸张尺寸(700像素长和200宽度)

 Private _pdPrint As PrintDocument
 Private _PaperSize As Printing.PaperSize


Public Sub DoPrinting()
    Try
        ' Start the print.
        _PaperSize = New PaperSize()
        _PaperSize.RawKind = Printing.PaperKind.Custom
        _PaperSize.Width = 300
        _PaperSize.Height = 200
        _PaperSize.PaperName = "Letter"

        _pdPrint.DefaultPageSettings.PaperSize = _PaperSize
        _pdPrint.PrinterSettings.DefaultPageSettings.PaperSize = _PaperSize



        _pdPrint.Print()
        If _exceptionFlag = True Then
            Throw New Exception
        End If
    Catch ex As Exception
        Throw
    End Try
End Sub

1 个答案:

答案 0 :(得分:1)

您需要添加事件PrintPageEventArgs

Private Sub PD_PrintPage_DrawImage(e As PrintPageEventArgs)

在此处添加代码