0
目前我正在使用silverlight 4,我們將基於Windows的應用程序轉換爲silverlight。在基於Windows的應用程序中打印字符串很容易使用COM,但像Silverlight這樣的客戶端應用程序可以打印字符串值嗎?Silverlight打印字符串值
我不得不將其轉換爲Silverlight的:
Dim PD As New PrintDialog
PD.UseEXDialog = True
PD.PrinterSettings = New System.Drawing.Printing.PrinterSettings
If (Windows.Forms.DialogResult.OK = PD.ShowDialog()) Then
ZPLZebra.RawPrinterHelper.SendStringToPrinter(PD.PrinterSettings.PrinterName, *******.ToString())
End If
編輯1:
public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, int dwCount)
{
IntPtr hPrinter = new IntPtr(0);
DOCINFOA di = new DOCINFOA();
bool flag = false;
di.pDocName = "My C#.NET RAW Document";
di.pDataType = "RAW";
if (OpenPrinter(szPrinterName, out hPrinter, 0L))
{
if (StartDocPrinter(hPrinter, 1, di))
{
if (StartPagePrinter(hPrinter))
{
int dwWritten = 0;
flag = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
}
if (!flag)
{
Marshal.GetLastWin32Error();
}
return flag;
}
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
int length = szString.Length;
IntPtr pBytes = Marshal.StringToCoTaskMemAnsi(szString);
SendBytesToPrinter(szPrinterName, pBytes, length);
Marshal.FreeCoTaskMem(pBytes);
return true;
}
編號:(這是我確切的要求) - Printing "raw text" (ZPL) from Web
感謝您的回覆,打印文檔將只需要要打印的文件,我們不能原始文本發送到打印機。 – Prabu
我需要發送字符串值給打印機,而不是文件,如圖像或文檔 – Prabu
我添加了代碼來說明答案:D這是您等待的答案嗎? – Tonio