我正在尝试在Windows服务中打印。使用以下VB.Net代码:
Dim _pd As New System.Drawing.Printing.PrintDocument()
AddHandler _pd.PrintPage, New System.Drawing.Printing.PrintPageEventHandler(AddressOf PrintDocument_PrintPage)
AddHandler _pd.EndPrint, New System.Drawing.Printing.PrintEventHandler(AddressOf PrintDocument_EndPrint)
_pd.Print()
EventHandlers已实施并经过测试。当我运行代码(使用AccountType:User)时,我得到一个例外,说“没有安装打印机”。在Windows窗体应用程序中,一切正常。
我正在使用网络打印机。
提前谢谢你, 亚历山大
答案 0 :(得分:1)
不建议在Windows服务中打印。
您需要使用different account作为您的服务(域帐户),以便您可以访问网络资源。
您可以在以下网址找到更多信息:Network printing with window service
答案 1 :(得分:1)
试试这段代码,它可以让你打印任何东西:
<script src="https://maps.googleapis.com/maps/api/js?&libraries=places&callback=initAutocomplete" async defer></script>
答案 2 :(得分:0)
您可以借助Windows API通过Windows服务进行打印。 System.Drawing.Printing与服务不兼容。