vb.netcad打印,vb 打印
vb.net 打印功能
可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。
企业建站必须是能够以充分展现企业形象为主要目的,是企业文化与产品对外扩展宣传的重要窗口,一个合格的网站不仅仅能为公司带来巨大的互联网上的收集和信息发布平台,创新互联面向各种领域:户外休闲椅等成都网站设计、营销型网站解决方案、网站设计等建站排名服务。
也可以做成vb报表(VB自带有)。
先设置报表格式,打印时向报表传递数据就可以了。
vb.net 打印问题
可以将打印机默认打印设置改为黑白打印,如果打印对象是RGB配色,打印机驱动转换为CMYK颜色时,黑色都是由彩色墨水组成的
2.可以试一下图片从一个标准灰度图片格式化而来,这样图片自身只有黑白色,也许可以
在vb中如何调用autocad进行打印
''''取得当前文档对象 VB a中的方法,如果是在VB中时需要从顶层对象开始引用取得)
Dim currentDoc As AcadDocument
Set currentDoc = ThisDrawing
''''文档的模型空间
Dim sp As AcadModelSpace
Set sp = currentDoc.modelspace
''''取得模型空间中的块属性
Dim index As Integer
For index = 0 To sp.Count - 1
Dim name As String
name = sp.Item(index).ObjectName
''''判断模型空间中的项目是否是一个块引用
If name Like "*Ac*" Then
Dim blockRef As AcadBlockReference
Set blockRef = sp.Item(index)
''''块引用的插入点
Dim insertPoint As Variant
insertPoint = blockRef.InsertionPoint
''''放大比例
Dim xScale, yScale As Integer
xScale = blockRef.XScaleFactor
yScale = blockRef.YScaleFactor
''''宽高基数
Dim width, height As Double
width = 297
height = 210
''''打印区域
Dim UpperRight(0 To 1) As Double, LowerLeft(0 To 1) As Double
UpperRight(0) = insertPoint(0)
UpperRight(1) = insertPoint(1)
LowerLeft(0) = insertPoint(0) + width * xScale
LowerLeft(1) = insertPoint(1) - height * yScale
list.AddItem "inserPoint:X=" UpperRight(0) " Y:" UpperRight(1)
list.AddItem "lowerLeft :X=" LowerLeft(0) " Y:" LowerLeft(1)
Dim plotConfs As AcadPlotConfigurations
Set plotConfs = ThisDrawing.PlotConfigurations
list.AddItem plotConfs.Count
Dim plotconf As AcadPlotConfiguration
Set plotconf = plotConfs.Add("plot")
''''list.AddItem plotconf.GetPlotDeviceNames(5)
''''Set plotConf = ThisDrawing.PlotConfigurations.Add
''''设置定义要打印的布局范围的坐标
ThisDrawing.ActiveLayout.SetWindowToPlot LowerLeft, UpperRight
''''指定布局或打印配置的类型
ThisDrawing.ActiveLayout.PlotType = acWindow
''''按局部或完整视图预览方式显示打印预览对话框
ThisDrawing.Plot.DisplayPlotPreview acFullPreview
''''打印布局到设备
ThisDrawing.Plot.PlotToDevice
End If
Next index
VB.NET打印编程问题,打印机为激光打印机。
打印做得不多,以前做套打时发现,每台打印机定位都不一样,于是每台机子都加了个偏移设置
我的做法在白纸上打上一标尺,和一个上下边距为2CM的交叉点,然后用标尺量这2CM的偏移,设置完后,在这台打印机打印时,就给纸张加个偏移量,打印就正常了。可能你的原因和我一样。
另外也想问你一下,你这个条码是用什么打的。早先,我用立象的条码打印机打不干胶,很简单,激光打没用过,可能下次我也要用条码打印,我也用VB.net。求教.
VB.NET 打印问题。
先拖过来控件PrintDocument1,然后双击PrintDocument1,在它的PrintPage事件中加入代码如下:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
dim a as String
a="abcd"
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString(a, New Font("宋体", 20), New Pen(Color.Black, 1).Brush, 30, 30)
End Sub
调用下面语句可直接用默认打印机打印出来:
PrintDocument1.Print()
如何用.NET将DWG文件打印为PDF
因为有人问到,所以写了个例子。具体的要求是从.NET(比如C#)里面调用AutoCAD ActiveX API实现后台打印DWG文件为PDF文件,而且要把打印页面的大小设置成和DWG视图的页面的大小一致。当然除了ActiveX API,其它接口,比如ObjectARX和AutoCAD.NET API也支持打印并能实现上述功能的。不过我们今天就限定一下范围,用一用ActiveX API,而且指定产品是AutoCAD 2010吧。
执行步骤:打开一个dwg文件,用netload加载下面代码所在的.dll文件,再输入命令plottest,就得到输出结果(一个.pdf文件)。
要用到的参考:
AcDbMgd.dll;AcMgd.dll;AutoCAD 2010 Type Library;System.Windows.Forms; AutoCAD/ObjectDBX Common 18.0 Type Library.
VB.NET:
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Autodesk.AutoCAD.Runtime.CommandMethod("Plottest") _
Public Sub PlotToPDF()
Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ThisDrawing As AcadDocument = CType(activeDoc.AcadDocument, AcadDocument)
Dim layout As AcadLayout = ThisDrawing.ActiveLayout
Dim MediaName As String = layout.CanonicalMediaName
If MediaName.Equals("") Then
activeDoc.Editor.WriteMessage("There is no media set for the active layout.")
Return
Else
activeDoc.Editor.WriteMessage(("The media for the active layout is: " + MediaName))
End If
Try
Dim oplot As AcadPlotConfiguration = ThisDrawing.PlotConfigurations.Add("PDF", layout.ModelType)
oplot.PaperUnits = AcPlotPaperUnits.acMillimeters
oplot.StyleSheet = "monochrome.ctb"
oplot.PlotWithPlotStyles = True
oplot.ConfigName = "DWG To PDF.pc3"
oplot.UseStandardScale = True
oplot.StandardScale = AcPlotScale.acScaleToFit
oplot.PlotType = AcPlotType.acExtents
oplot.CenterPlot = True
Dim oMediaNames As Object = layout.GetCanonicalMediaNames
Dim mediaNames As ArrayList = New ArrayList(CType(oMediaNames, String()))
For Each sName As String In mediaNames
If sName.Contains(MediaName) Then
oplot.CanonicalMediaName = sName
layout.CopyFrom(oplot)
layout.PlotRotation = AcPlotRotation.ac0degrees
layout.RefreshPlotDeviceInfo()
ThisDrawing.SetVariable("BACKGROUNDPLOT", 0)
ThisDrawing.Plot.QuietErrorMode = True
ThisDrawing.Plot.PlotToFile("c:/temp/d1.pdf", "DWG To PDF.pc3")
oplot.Delete()
oplot = Nothing
Return
End If
Next
Catch es As System.Exception
System.Windows.Forms.MessageBox.Show(es.ToString)
End Try
End Sub
C#:
using System;
using System.Collections;
using System.Collections.Specialized;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
// Define Command "plotTest"
[CommandMethod("plotTest")]
static public void PlotToPDF()
{
Document activeDoc = Application.DocumentManager.MdiActiveDocument;
AcadDocument ThisDrawing = activeDoc.AcadDocument as AcadDocument;
AcadLayout layout = ThisDrawing.ActiveLayout;
String MediaName = layout.CanonicalMediaName;
if (MediaName.Equals(""))
{
activeDoc.Editor.WriteMessage("There is no media set for the active layout.");
return;
}
else
{
activeDoc.Editor.WriteMessage("The media for the active layout is: " + MediaName);
}
try
{
AcadPlotConfiguration oplot = ThisDrawing.PlotConfigurations.Add("PDF", layout.ModelType);
oplot.PaperUnits = AcPlotPaperUnits.acMillimeters;
oplot.StyleSheet = "monochrome.ctb";
oplot.PlotWithPlotStyles = true;
oplot.ConfigName = "DWG To PDF.pc3";
oplot.UseStandardScale = true;
oplot.StandardScale = AcPlotScale.acScaleToFit;
oplot.PlotType = AcPlotType.acExtents;
oplot.CenterPlot = true;
Object oMediaNames = layout.GetCanonicalMediaNames();
ArrayList mediaNames = new ArrayList((string[])oMediaNames);
foreach (String sName in mediaNames)
{
if (sName.Contains(MediaName))
{
oplot.CanonicalMediaName = sName;
layout.CopyFrom(oplot);
layout.PlotRotation = AcPlotRotation.ac0degrees;
layout.RefreshPlotDeviceInfo();
ThisDrawing.SetVariable("BACKGROUNDPLOT", 0);
ThisDrawing.Plot.QuietErrorMode = true;
ThisDrawing.Plot.PlotToFile("c://temp//d1.pdf","DWG To PDF.pc3");
oplot.Delete();
oplot=null;
return;
}
}
}
catch (System.Exception es)
{
System.Windows.Forms.MessageBox.Show(es.ToString());
}
}
输出结果:
网页标题:vb.netcad打印,vb 打印
URL分享:http://azwzsj.com/article/heescs.html