Tag: 打印

如何从C#网络上的IP访问打印机名称?

我可以使用名称“\\ xxxx \ [打印机名称]”访问打印机,但不知道如何仅使用打印机的IP访问它。 有任何想法吗? 编辑:答案似乎表明我可以简单地换掉打印机的IP地址的打印机名称,但似乎并非如此。 还有更多想法吗? 更新:将打印机作为IP进行寻址的原因是,网络人员给所有打印机提供了相同的共享名称,因此除了IP之外,我无法区分它们。

在C#中确定打印机的IP地址

我想使用C#(.NET 2.0)确定打印机的IP地址。 我只有Windows操作系统上设置的打印机共享名称,格式为\\PC Name\Printer Name 。 打印机是网络打印机,具有与PC不同的IP地址。 有没有人有任何指针? 在此先感谢您的帮助。 此致,安迪。

自动将文字换行到打印页面?

我有一些打印字符串的代码,但如果字符串是:“Blah blah blah”…并且没有换行符,则文本占用一行。 我希望能够塑造字符串,使其字形包裹在纸张的尺寸上。 private void PrintIt(){ PrintDocument document = new PrintDocument(); document.PrintPage += (sender, e) => Document_PrintText(e, inputString); document.Print(); } static private void Document_PrintText(PrintPageEventArgs e, string inputString) { e.Graphics.DrawString(inputString, new Font(“Courier New”, 12), Brushes.Black, 0, 0); } 我想我可以找出一个字符的长度,并手动包装文本,但如果有一个内置的方法来做到这一点,我宁愿这样做。 谢谢!

iTextSharp打印gridview

我使用iTextSharp打印网格视图但我遇到了一些问题: 根本没有阿拉伯字符出现。 方向是LTR,而不是RTL。 gridview中的一些列是templatefields(label,imagebutton,…),我无法处理这种情况。 我不会显示所有这些(如删除按钮,…) 代码 : protected void ExportToPDF(GridView gvReport, bool LandScape) { int noOfColumns = 0, noOfRows = 0; DataTable tbl = null; if (gvReport.AutoGenerateColumns) { tbl = gvReport.DataSource as DataTable; // Gets the DataSource of the GridView Control. noOfColumns = tbl.Columns.Count; noOfRows = tbl.Rows.Count; } else { noOfColumns = gvReport.Columns.Count; noOfRows = […]

如何从WinForms打印多个页面?

虽然网上有一些教程,但我仍然不知道为什么这不能正确打印多个页面。 我究竟做错了什么? public static void printTest() { PrintDialog printDialog1 = new PrintDialog(); PrintDocument printDocument1 = new PrintDocument(); printDialog1.Document = printDocument1; printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); DialogResult result = printDialog1.ShowDialog(); if (result == DialogResult.OK) { printDocument1.Print(); } } static void printDocument1_PrintPage(object sender, PrintPageEventArgs e) { Graphics graphic = e.Graphics; SolidBrush brush = new SolidBrush(Color.Black); Font font = […]

印刷质量winform

尝试从WinForms应用程序打印时遇到2个问题。 无论我尝试什么,第一个是非常糟糕的质量。 第二个是我左上角有一个很大的页边距,而winform正在切割。 有任何想法吗? 这是我的代码: Bitmap MemoryImage; public void GetPrintArea(Panel pnl) { MemoryImage = new Bitmap(pnl.Width, pnl.Height); Rectangle rect = new Rectangle(0, 0, pnl.Width, pnl.Height); pnl.DrawToBitmap(MemoryImage, new Rectangle(0, 0, pnl.Width, pnl.Height)); } protected override void OnPaint(PaintEventArgs e) { if (MemoryImage != null) { e.Graphics.DrawImage(MemoryImage, 0, 0); base.OnPaint(e); } } void printdoc1_PrintPage(object sender, PrintPageEventArgs e) { […]

如何将页面剪切命令发送到Epson打印机

我正在尝试通过向打印机发送剪纸命令(带USB端口的Epson TM U220)实际剪切纸张。 我使用了打印机与Generic / Text Only Driver和Epson打印机端口,我在安装Epson高级打印机驱动程序后找到了该端口。 打印机命令代码是(GS V m),其中m = 0,1,48或49,我在设备手册中找到了它。 我想知道如何通过StringWriter将这些命令发送到打印机。 我使用Generic / Text Only打印机,因为它比使用Epson驱动程序快得多。 我是C#windows的新手,请任何人为我提供一些代码来实现这一目标。 我已经在网上冲浪了好几天还没有找到答案。 我想我需要发送打印机命令作为字节,但我不知道该怎么做:(

如何从打印机队列中检索列表或作业数?

我正在寻找一种从特定打印机获取列表​​或作业数量的方法。 在最好的情况下,我希望有一个“作业对象”代表一个打印作业及其在打印队列中的名称。 这是必需的,因为我需要监视打印机的状态,这样我就可以用新的一批文件重新填充打印队列而不会溢出打印假脱机程序 提前致谢! 编辑:添加解决方案的代码片段 private int GetNumberOfPrintJobs() { LocalPrintServer server = new LocalPrintServer(); PrintQueueCollection queueCollection = server.GetPrintQueues(); PrintQueue printQueue = null; foreach (PrintQueue pq in queueCollection) { if (pq.FullName == PrinterName) printQueue = pq; } int numberOfJobs = 0; if (printQueue != null) numberOfJobs = printQueue.NumberOfJobs; return numberOfJobs; }

使用c#将txt打印到默认打印机

有没有办法使用c#将.txt发送到打印机? 就像是 string doc = “c:\temp.txt”; sendToPrinter(doc);

ASP.NET MVC中以编程方式“hello world”默认的SERVER端打印机

我安装了打印机并在Intranet服务器上工作,我想以编程方式将“hello world”发送到该默认打印机。 这似乎是最简单的事情,但我一直在谷歌搜索几个小时没有成功。 (注意:我正在运行Windows 7的部署机器上开发asp.net mvc) 我试图将VB中的一个例子翻译成C#,但它说“没有安装打印机”。 public void TestPrint() { var x = new PrintDocument(); x.PrintPage += new PrintPageEventHandler(PrintPage); x.Print(); } private void PrintPage(Object sender, PrintPageEventArgs e) { var textToPrint = “Hello world”; var printFont = new Font(“Courier New”, 12); var leftMargin = e.MarginBounds.Left; var topMargin = e.MarginBounds.Top; e.Graphics.DrawString(textToPrint, printFont, Brushes.Black, leftMargin, topMargin); } […]