如何确定打印机是否是票证打印机VB.NET [英] How to determine if a printer is a ticket-printer VB.NET

查看:107
本文介绍了如何确定打印机是否是票证打印机VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,



我正在尝试扩展我们在项目中用作处理打印的内部打印组件。

我正在研究的项目之一需要根据默认打印机的类型(A4 officejet,ticketprinter,A5打印机)确定输出格式的类型(票证,名牌,A4,...) ,...)为了正确安排布局等。想法是你向这个程序发送命令,并且它将以正确的格式生成适当的打印作业。



我主要在确定打印机是否是票据打印机时遇到问题。门票往往有一个可变的长度,所以我有点寻找PaperSetting属性,我可以查询,以了解我们是否使用票据打印机,但到目前为止无济于事。不确定是否有其他方法可以找出我们正在使用的打印机类型。



在过去几天里,我无法找到任何方法来确定打印机打印的默认格式类型。

任何帮助都会受到赞赏,虽然我开始认为没有简单的方法可以询问任何打印机他们有什么类型的打印机。



谢谢提前帮忙!



Greets,

David



我尝试了什么:



我试过玩一些属性。

PaperKind属性返回自定义,但由于我们还有一些其他格式的工业打印机也会返回...这不是很有用。

创建一个我们必须在所有票据打印机上设置的命名自定义纸张样式并不是真正的选择,因为我们谈论的是数百台打印机。

我使用PaperSize进行排序试着猜猜我们正在使用什么类型的纸张,但我不确定这是否可靠,因为我们的标签宽度与门票的宽度相同。它确实做了我想做的工作,但正如我所说,我并没有真正找到一种干净的方法来确定它。

Greetings,

I'm trying to expand an inhouse printing-component that we use as reference in our projects to handle printing.
One of the projects I'm working on needs to determine the type of output format (ticket, nametag, A4,...) based on the default printer's type (A4 officejet, ticketprinter, A5 printer,...) in order to properly arrange the layout etc. The idea being that you send a command to this program and that it'll generate the appropriate print-job in the right format.

I'm mainly having issues with determining if a printer is a ticket-printer. Tickets tend to have a variable length, so I was sort of looking for PaperSetting-properties that I could query in order to find out if we're using a ticket printer, but to no avail so far. Not sure if there'd be another way to find out what type of printer we're using.

Over the last couple of days, I haven't been able to find any way to determine what type of default format the printer prints in.
Any help would be appreciated, though I'm starting to think there's no easy way to just ask any printer what type of printer they have.

Thanks in advance for any help!

Greets,
David

What I have tried:

I've tried playing around with some properties.
The PaperKind property returns "custom", but as we have a few other industrial printers with other formats that also return this... it's not very useful.
Creating a named custom paper style that we'd have to set up on all ticket printers isn't really an option, as we're talking about hundreds of printers.
I've used the PaperSize to sort of try and guess what type of paper we're using, but I'm not sure that's reliable considering we have tags that are sort of the same width as tickets too. It does kind of do the job I suppose, but as I said I don't really find it a "clean" way to determine it.

推荐答案

不确定那里是什么会自动完成 - 票务打印机毕竟只是一个特定的格式打印机 - 但有 PrinterSettings.PaperSizes属性(System.Drawing.Printing)| Microsoft Docs [ ^ ]返回支持的纸张尺寸的集合。据推测,票据打印机将支持特定尺寸而不是A4,A3等。

Not sure there is anything which will do it automatically - a ticket printer is just a specific format printer after all - but there is the PrinterSettings.PaperSizes Property (System.Drawing.Printing) | Microsoft Docs[^] which returns a collection of supported paper sizes. Presumably, the ticket printer will support specific sizes rather than A4, A3, etc.
PrinterSettings ps = new PrinterSettings();         // Gets default printer
Console.WriteLine(ps.PrinterName);
foreach (PaperSize paperSize in ps.PaperSizes)
    {
    Console.WriteLine("{0}: ({1}, {2})", paperSize.PaperName, paperSize.Width, paperSize.Height);
    }

给我这些爱普生BX305:

Gives me these for my Epson BX305:

EPSON4782F5 (Epson Stylus Office BX305)
A4 210 x 297 mm: (827, 1169)
10 x 15 cm (4 x 6 in): (400, 600)
13 x 18 cm (5 x 7 in): (500, 700)
A6 105 x 148 mm: (413, 583)
A5 148 x 210 mm: (583, 827)
B5 182 x 257 mm: (717, 1012)
9 x 13 cm (3.5 x 5 in): (350, 500)
13 x 20 cm (5 x 8 in): (500, 800)
20 x 25 cm (8 x 10 in): (800, 1000)
16:9 wide size (102 x 181 mm): (400, 711)
100 x 148 mm: (394, 583)
Envelope #10 4 1/8 x 9 1/2 in: (413, 950)
Envelope DL  110 x 220 mm: (433, 866)
Envelope C6  114 x 162 mm: (449, 638)
Letter 8 1/2 x 11 in: (850, 1100)
Legal 8 1/2 x 14 in: (850, 1400)
A3 297 x 420 mm: (1169, 1654)
A3+ 329 x 483 mm: (1295, 1902)
A2 420 x 594 mm: (1654, 2339)
B4 257 x 364 mm: (1012, 1433)
B3 364 x 515 mm: (1433, 2028)
User Defined: (827, 1169)


这篇关于如何确定打印机是否是票证打印机VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆