如何在C#中打印PCL文件? [英] How do I print a PCL file in C#?

查看:356
本文介绍了如何在C#中打印PCL文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用打印到文件"生成的PCL文件.

I have a PCL file that I generated using "print to file".

在C#中以编程方式打印此文件的最佳方法是什么?

What's the best way to programmatically print this file in C#?

(当然,因为我要打印的打印机支持PCL.)

(Given of course that the printer I am printing to supports PCL.)

我知道我可以通过从提示符处调用来进行打印:

I know that I can print by invoking from a prompt:

copy filename.pcl //location/printername

所以我想我也可以通过编程方式(使用复制)来做同样的事情……我想知道是否有更干净的方法来做到这一点,比如说使用PrintDocument.

So I would imagine that I could also do the same thing programmatically (using copy)... I wonder if there is a cleaner way to do this, say using PrintDocument.

请注意,当我使用PrintDocument时:

Note that when I use PrintDocument:

var pd = new PrintDocument
         {
             DocumentName = @"filename.pcl";
             PrinterSettings = {PrinterName = @"\\location\printername"}
         };

pd.Print();

我总是打印空白页.

推荐答案

本文适用于Visual Basic ,但是我认为很容易就能将其应用于C#.否则,我会很乐意为您解决任何有问题的部分.

This article applies to Visual Basic, but it is easy enough to follow to be able to apply it to C#, I think. Otherwise, I'll gladly assist you with any problematic parts.

如果打印机在网络上,则这里有个有趣的例子,说明了如何直接与之交谈.如果只是将PCL的字节发送到打印机,则不确定是否也可以.

If the printer is on the network, here's a little funny example of how to talk directly to it. Not sure if it also works if you simply send the bytes of the PCL to the printer though.

这篇关于如何在C#中打印PCL文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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