我已創建自定義紙張尺寸自定義紙張尺寸「人聯黨15×14」在Setting - Printers - File - Server Properties.
現在我想要使用VB.net 2005編程設置水晶報表
當設置自定義紙張尺寸的水晶報表我從VB.net運行報表,Crystal報表查看器顯示自定義紙張尺寸的正確預覽,但是當我給出打印命令時,它將使用默認打印機紙張尺寸進行打印。 (如Letter)
下面是我用打印的代碼:
Public Sub ...
'...
Dim ObjCrReport as new ReportDocument
'...
ObjCrReport.SetDataSource(ObjPrintDataSet.Tables("PrintData"))
SetReportPageSize("SUPP 15 x 14", 1)
'...
End Sub
Private Sub BtnPrintDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrintDoc.Click
Try
'Print command
ObjCrReport.PrintToPrinter(1, False, 0, 0)
Catch ex As Exception
MessageBox.Show(ex.Message, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Public Sub SetReportPageSize(ByVal mPaperSize As String, ByVal PaperOrientation As Integer)
Try
Dim ObjPrinterSetting As New System.Drawing.Printing.PrinterSettings
Dim PkSize As New System.Drawing.Printing.PaperSize
ObjPrinterSetting.PrinterName = "Epson FX1170"
For i As Integer = 0 To ObjPrinterSetting.PaperSizes.Count - 1
If ObjPrinterSetting.PaperSizes.Item(i).PaperName = mPaperSize.Trim Then
PkSize = ObjPrinterSetting.PaperSizes.Item(i)
Exit For
End If
Next
If PkSize IsNot Nothing Then
Dim myAppPrintOptions As CrystalDecisions.CrystalReports.Engine.PrintOptions = ObjCrReport.PrintOptions
myAppPrintOptions.PrinterName = "Epson FX1170"
myAppPrintOptions.PaperSize = CType(PkSize.RawKind, CrystalDecisions.Shared.PaperSize)
ObjCrReport.PrintOptions.PaperOrientation = IIf(PaperOrientation = 1, _
CrystalDecisions.Shared.PaperOrientation.Portrait, _
CrystalDecisions.Shared.PaperOrientation.Landscape)
End If
PkSize = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
如果我使用myAppPrintOptions.PaperSize = PaperSize.PaperLegal
,然後點擊打印預覽&印刷出現正確的,但我要的是設定不顯示自定義紙張尺寸在PaperSize
類中。
上述代碼有什麼問題?爲什麼打印Letter Size時Crystal Report預覽會在大小預覽中顯示自定義紙張?有沒有更好的方法來實現我的目標?
沒有人有任何答案?我在工作中遇到了完全相同的問題。 –
默認情況下,可能是Printer設置爲_「Letter Size」_。現在還沒有答案,現在是2016年 –