[英]How to print files stored at your local hard drive in C#?
我有一個用C#(WinForms)創建的函數,將文件另存為gif圖像在本地目錄中。 如何訪問它並將其發送到我的一台網絡打印機進行打印?
我現在在這里有此代碼:
internal void PrintLabels(string printerInfo, List<string> shippingLabels)
{
//this is where I print to printer...
foreach (string labelPath in shippingLabels)
{
}
}
有什么幫助嗎?
我有一堆“ gif”圖像。 您的所有鏈接均適用於.txt文件。 這是我的代碼:
public void PrintShippingLabels()
{
//mock of what the reset of the program will produce up to this step
List<string> shippingLabels = new List<string>();
for (var i = 0; i < 10; i++)
{
var trackingNumber = "1ZR02XXXXXXXXXXXXX" + i + ".gif";
shippingLabels.Add(trackingNumber);
CreateSampleShippingLabel(trackingNumber);
}
Assert.AreEqual(10, shippingLabels.Count);
IceTechUPSClient.Instance.PrintLabels("", shippingLabels);
}
public void PrintLabels(List<string> shippingLabels)
{
//this is where I print to printer...
PrintDocument pd = new PrintDocument();
foreach (string labelPath in shippingLabels)
{
pd.Print();
}
}
檢查您的打印機。 現在,某些設備可以本地打印gif,jpeg,tiff等,而無需轉換為PCL或PostScript數據流(或其他打印語言)。 如果是這種情況,您可以直接通過LPR協議,直接通過端口9100或直接通過Windows打印隊列發送文件( http://support.microsoft.com/kb/322091 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.