full height([紧急求助]mapx 如何打印任何尺寸纸张)
本文目录
[紧急求助]mapx 如何打印任何尺寸纸张
提供以下代码作参考:Imports AxMDrawProLibImports System.Windows.FormsImports System.DrawingImports System.Drawing.Printing’Imports PictureCtrl.PublicLayerPublic Class CMetaDrawPrinter#Region “类说明及修改日志“’ 修改人:’ 修改内容:#End Region’声明事件Private WithEvents PrnDocMetaDraw As PrintDocument’传递控件的临时变量Private _MetaDrawCtrl As AxMDrawPro’传递剪裁、输出区域的信息Private _PicType As MDrawProLib.C_PictureTypePrivate _sClipLeft, _sClipTop, _sClipWidth, _sClipHeight, _sExportLeft, _sExportTop, _sExportWidth, _sExportHeight, _sBlankLength, _sFullHeight, _sFullWidth As SinglePrivate _iPageNum, _iPrintPageNum As Integer’纸型高、宽Private _iPaperHeight, _iPaperWidth As Integer’纸型:A4/A3Private _iPaperKind As System.Drawing.Printing.PaperKind’横纵打印Private _bPaperLandscape As Boolean’输出属性Private _ExportOptions As MDrawProLib.C_ExportOptions’打印机和显示器的DPI,暂时不加入此类中,由外部控制’Private _iPrinterDPI, _iMonitorDPI As Integer#Region “属性“’获取当前使用的PrintDocument类Public ReadOnly Property GetPrnDoc()GetReturn PrnDocMetaDrawEnd GetEnd Property’全图(大图)高度Public Property FullHeight() As SingleGetReturn _sFullHeightEnd GetSet(ByVal Value As Single)_sFullHeight = ValueEnd SetEnd Property’全图(大图)宽度Public Property FullWidth() As SingleGetReturn _sFullWidthEnd GetSet(ByVal Value As Single)_sFullWidth = ValueEnd SetEnd Property’2页之间的空白区域长度Public Property BlankLength() As SingleGetReturn _sBlankLengthEnd GetSet(ByVal Value As Single)_sBlankLength = ValueEnd SetEnd Property’输出的页数Public Property PageNum() As IntegerGetReturn _iPageNumEnd GetSet(ByVal Value As Integer)_iPageNum = ValueEnd SetEnd Property’ 获取输出图片格式Private ReadOnly Property PicType() As MDrawProLib.C_PictureTypeGetReturn _PicTypeEnd Get’Set(ByVal Value As MDrawProLib.C_PictureType)’ _PicType = Value’End SetEnd Property’得到当前使用的MetaDraw控件Private WriteOnly Property GetMetaDrawCtrl() As AxMDrawProSet(ByVal Value As AxMDrawPro)_MetaDrawCtrl = ValueEnd SetEnd Property’得到当前使用的MetaDraw控件Public WriteOnly Property SetExportOptions() As MDrawProLib.C_ExportOptionsSet(ByVal Value As MDrawProLib.C_ExportOptions)_ExportOptions = ValueEnd SetEnd Property#Region “纸张“’纸张:高Public Property PaperKind() As PaperKindGetReturn _iPaperKindEnd GetSet(ByVal Value As PaperKind)_iPaperKind = ValueEnd SetEnd Property’纸张:高Public Property PaperHeight() As IntegerGetReturn _iPaperHeightEnd GetSet(ByVal Value As Integer)_iPaperHeight = ValueEnd SetEnd Property’纸张:宽Public Property PaperWidth() As IntegerGetReturn _iPaperWidthEnd GetSet(ByVal Value As Integer)_iPaperWidth = ValueEnd SetEnd Property’纸张:横纵Public Property PaperLandscape() As BooleanGetReturn _bPaperLandscapeEnd GetSet(ByVal Value As Boolean)_bPaperLandscape = ValueEnd SetEnd Property#End Region#Region “剪裁区域信息“Public Property ClipLeft() As SingleGetReturn _sClipLeftEnd GetSet(ByVal Value As Single)_sClipLeft = ValueEnd SetEnd Property’剪裁上边距Public Property ClipTop() As SingleGetReturn _sClipTopEnd GetSet(ByVal Value As Single)_sClipTop = ValueEnd SetEnd Property’剪裁宽度Public Property ClipWidth() As SingleGetReturn _sClipWidthEnd GetSet(ByVal Value As Single)_sClipWidth = ValueEnd SetEnd Property’剪裁高度Public Property ClipHeight() As SingleGetReturn _sClipHeightEnd GetSet(ByVal Value As Single)_sClipHeight = ValueEnd SetEnd Property#End Region#Region “输出区域信息“’输出左边距Public Property ExportLeft() As SingleGetReturn _sExportLeftEnd GetSet(ByVal Value As Single)_sExportLeft = ValueEnd SetEnd Property’输出上边距Public Property ExportTop() As SingleGetReturn _sExportTopEnd GetSet(ByVal Value As Single)_sExportTop = ValueEnd SetEnd Property’输出宽度Public Property ExportWidth() As SingleGetReturn _sExportWidthEnd GetSet(ByVal Value As Single)_sExportWidth = ValueEnd SetEnd Property’输出高度Public Property ExportHeight() As SingleGetReturn _sExportHeightEnd GetSet(ByVal Value As Single)_sExportHeight = ValueEnd SetEnd Property#End Region#End Region#Region “SUB方法“Public Sub New(ByVal _MetaDrawCtrlTemp As AxMDrawPro)PrnDocMetaDraw = New PrintDocument’PrnDocMetaDraw.PrinterSettings.DefaultPageSettings.Landscape = True’PrnDocMetaDraw.PrinterSettings.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize(“Custom“, 1169, 827)_MetaDrawCtrl = _MetaDrawCtrlTemp’默认的纸型设置_iPaperKind = PaperKind.A4_bPaperLandscape = True’默认值’图象格式_PicType = MDrawProLib.C_PictureType.PICTYPE_ENHMETAFILE’_PicType = MDrawProLib.C_PictureType.PICTYPE_METAFILE’四周空白区域(边距),_BlankHeight * 2 = 2个小图的间距_sBlankLength = 0’默认剪裁区域信息_sClipLeft = _sBlankLength_sClipTop = _sBlankLength_sClipWidth = 100_sClipHeight = 100’默认输出区域信息_sExportLeft = 0_sExportTop = 0_sExportWidth = 0_sExportHeight = 0’全图(大图)高度_sFullHeight = _MetaDrawCtrl.PicYSize’分成小图的页数_iPageNum = 1’页码清0_iPrintPageNum = 0End Sub’计算分页打印的页数Private Sub CountPageNum()Dim iPageX As IntegerDim iPageY As IntegerIf (_sFullWidth / _sClipWidth) 》 Int(_sFullWidth / _sClipWidth) TheniPageX = Int(_sFullWidth / _sClipWidth + 1)ElseiPageX = Int(_sFullWidth / _sClipWidth)End IfIf (_sFullHeight / _sClipHeight) 》 Int(_sFullHeight / _sClipHeight) TheniPageY = Int(_sFullHeight / _sClipHeight + 1)ElseiPageY = Int(_sFullHeight / _sClipHeight)End If_iPageNum = iPageX * iPageYIf _iPageNum 《 1 Then_iPageNum = 1End IfEnd Sub’Public Function GetClipImage() As Image’ _MetaDrawCtrl.PictureType = _PicType’ ’_MetaDrawCtrl.Current = MDrawProLib.C_ResHandle.OBJ_CONT_MAIN’ ’输出区域’ _MetaDrawCtrl.ExportOptions = MDrawProLib.C_ExportOptions.EXOPT_CLIPPING Or MDrawProLib.C_ExportOptions.EXOPT_USEZOOM’ ’剪切区域信息’ _MetaDrawCtrl.ClipLeft = _ClipLeft’ _MetaDrawCtrl.ClipTop = _ClipTop’ _MetaDrawCtrl.ClipWidth = _ClipWidth’ _MetaDrawCtrl.ClipHeight = _ClipHeight’ ’输出区域信息’ _MetaDrawCtrl.ExportLeft = _ExportLeft’ _MetaDrawCtrl.ExportTop = _ExportTop’ _MetaDrawCtrl.ExportWidth = _ExportWidth’ _MetaDrawCtrl.ExportHeight = _ExportHeight’ Return _MetaDrawCtrl.PictureClip’End Function’’计算小图页数’Private Sub CountPageNum()’ ’_iPageNum = Int((_sFullHeight / (_sClipHeight + _sBlankLength * 2)) * (_sFullWidth / (_sClipWidth + _sBlankLength * 2)))’ _iPageNum = Int((_sFullHeight * _sFullWidth) / ((_sClipHeight + _sBlankLength * 2) * (_sClipWidth + _sBlankLength * 2)))’ ’If _iPageNum 《 (_sFullHeight / (_sClipHeight + _sBlankLength * 2)) * (_sFullWidth / (_sClipWidth + _sBlankLength * 2)) Then’ If _iPageNum 《 (_sFullHeight * _sFullWidth) / ((_sClipHeight + _sBlankLength * 2) * (_sClipWidth + _sBlankLength * 2)) Then’ _iPageNum = _iPageNum + 1’ End If’ If _iPageNum 《 1 Then’ _iPageNum = 1’ End If’End SubPrivate Sub PrnDocMetaDraw_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrnDocMetaDraw.PrintPage’此处使用PICTYPE_BITMAP,没有PICTYPE_METAFILE清晰。’但是使用PICTYPE_METAFILE后, 某些元素角度会改变。_MetaDrawCtrl.PictureType = _PicType’_MetaDrawCtrl.Current = MDrawProLib.C_ResHandle.OBJ_CONT_MAIN’输出区域’加入EXOPT_USEZOOM是为了保持尺寸_MetaDrawCtrl.ExportOptions = _ExportOptions’_MetaDrawCtrl.ExportOptions = MDrawProLib.C_ExportOptions.EXOPT_CLIPPING’剪切区域信息_MetaDrawCtrl.ClipLeft = _sClipLeft_MetaDrawCtrl.ClipTop = _sClipTop’_MetaDrawCtrl.ClipWidth = 400’_MetaDrawCtrl.ClipHeight = 400_MetaDrawCtrl.ClipWidth = _sClipWidth_MetaDrawCtrl.ClipHeight = _sClipHeight’输出区域信息_MetaDrawCtrl.ExportLeft = _sExportLeft_MetaDrawCtrl.ExportTop = _sExportTop_MetaDrawCtrl.ExportWidth = _sExportWidth_MetaDrawCtrl.ExportHeight = _sExportHeight’_MetaDrawCtrl.ExportWidth = 400’_MetaDrawCtrl.ExportHeight = 400’设置打印区域尺寸’Dim RgleF As New RectangleF’Dim SizF As New SizeF’SizF.Height = iPrintHeight’SizF.Width = iPrintWidth’SizF.Height = _MetaDrawCtrl.PicYSize’SizF.Width = _MetaDrawCtrl.PicXSize’SizF.Height = 602’SizF.Width = 931’SizF.Height = mdpUser.PicYSize’SizF.Width = mdpUser.PicXSize’RgleF.Size = SizF’RgleF.X = _sExportLeft’RgleF.Y = _sExportTop’打印图象Dim _g As Graphics_g = e.Graphics_g.DrawImage(_MetaDrawCtrl.PictureClip, _sExportLeft, _sExportTop)’_g.DrawImage(_MetaDrawCtrl.PictureClip, RgleF)’’打印页码’_iPrintPageNum = 1 + _iPrintPageNum’Dim _Bursh As New SolidBrush(Color.Black)’Dim _Font As New System.Drawing.Font(“宋体, 9pt“, 9, FontStyle.Bold)’_g.DrawString(“页码:“ & _iPrintPageNum, _Font, _Bursh, 10, 10)’是否打印多页If _iPageNum 》= 2 Thene.HasMorePages = True_iPageNum = _iPageNum - 1’_BlankHeight为空白区域高度’横向平移打印_sClipLeft = _sClipLeft + _sClipWidth + _sBlankLength * 2’当横向结束后,向下纵向平移,重新开始纵向打印If _sClipLeft 》 _sFullWidth Then_sClipLeft = 0_sClipTop = _sClipTop + _sClipHeightEnd IfElsee.HasMorePages = FalseCountPageNum()_sClipLeft = 0_sClipTop = 0End If’’是否打印多页’If _iPageNum 》= 2 Then’ e.HasMorePages = True’ _iPageNum = _iPageNum - 1’ ’_BlankHeight为空白区域高度’ ’纵向打印’ _sClipTop = _sClipTop + _sClipHeight + _sBlankLength * 2’ ’当纵向结束后,向右横向平移,重新开始纵向打印’ If _sClipTop 》 _sFullHeight Then’ _sClipTop = 0’ _sClipLeft = _sClipLeft + _sClipWidth’ End If’Else’ e.HasMorePages = False’End IfEnd Sub#Region “注释掉部分-打印页码“’’打印函数子的函数,打印页码’Private Sub PrintPageNum()’ Dim _g As Graphics’ Dim _Bursh As New SolidBrush(Color.Black)’ Dim _Font As New System.Drawing.Font(“宋体, 9pt“, 9, FontStyle.Bold)’ _g.DrawString(“1“, _Font, _Bursh, 1, 1)’End Sub#End Region’打印Public Sub Print()’设置纸型SetupPaper()’得到页数CountPageNum()PrnDocMetaDraw.Print()End Sub’预览Public Sub Preview()Try’设置纸型SetupPaper()’得到页数CountPageNum()Dim _PreviewDialog As New PrintPreviewDialog’MsgBox(PrnDocMetaDraw.DefaultPageSettings.PaperSize.Kind)_PreviewDialog.Document = PrnDocMetaDraw_PreviewDialog.ShowDialog()Catch ex As ExceptionMsgBox(ex.ToString)End TryEnd SubPublic Sub PrinterSetup()Dim _PrintDialog As New PrintDialog_PrintDialog.Document = PrnDocMetaDraw_PrintDialog.ShowDialog()End SubPublic Sub PageSetup()Dim _PageSetupDialog As New PageSetupDialog_PageSetupDialog.Document = PrnDocMetaDraw_PageSetupDialog.ShowDialog()End Sub’局部调用,设置纸型:横纵向、高、宽。Private Sub SetupPaper()Try’PrnDocMetaDraw.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize(“Custom“, _iPaperWidth, _iPaperHeight)PrnDocMetaDraw.DefaultPageSettings.Landscape = _bPaperLandscapeDim tPaperSize As PaperSizeDim i As IntegerFor i = 0 To PrnDocMetaDraw.PrinterSettings.PaperSizes.Count - 1If PrnDocMetaDraw.PrinterSettings.PaperSizes(i).Kind = _iPaperKind ThentPaperSize = PrnDocMetaDraw.PrinterSettings.PaperSizes(i)Exit ForEnd IfNextPrnDocMetaDraw.DefaultPageSettings.PaperSize = tPaperSize’PrnDocMetaDraw.DefaultPageSettings.PaperSize = System.Drawing.Printing.PaperKind.A4Catch ex As ExceptionMsgBox(ex.ToString)End TryEnd Sub#End RegionEnd Class
full-height PCI 2.3 slot是什么意思
full-height就是全高,还有half-length(半高),full-length(全长)等。PCI2.3就是支持V2.3规范的PCI接口。slot就是插槽。全高是一般PC里面用的, 半高比全高在高度上矮,一般用于mini机箱等结构紧凑的地方。
更多文章:

scanf返回值被忽略是怎么回事(忽略scanf的返回值要怎么改pta)
2025年3月18日 18:00

filterconfig(java关于ServletConfig FilterConfig什么用)
2025年3月8日 18:20

ftp怎么用资源管理器打开(如何在资源管理器中打开ftp,而不会自动跳到在google浏览器或者IE中打开)
2025年3月15日 14:00

微信小程序怎么制作自己的程序(制作微信小程序需要准备什么,可以自己制作吗)
2025年2月12日 15:20

yielded是什么意思(yield spread是什么意思)
2025年2月16日 01:20

typescript什么意思(typescript constructor是什么意思)
2025年3月19日 22:40

htmlform添加接口(一个HTML里有两个form如何把这两个form绑定一起)
2025年2月10日 02:30

crossing field(刀剑神域op1 crossing field歌词(罗马音+日文+中文))
2025年2月11日 07:10

苹果无法验证的app怎么打开?苹果无法验证app完整性怎么解决
2025年2月27日 22:20