目前我正在使用 silverlight 4,我们正在将基于 windows 的应用程序转换为 silverlight。在基于 Windows 的应用程序中使用 COM 打印字符串很容易,但是像 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;
}
参考:(这是我的确切要求)-从 Web 打印“原始文本”(ZPL)