У меня есть приложение C # WPF Desktop на планшете, которое подключено через USB-кабель к принтеру.Когда я пытаюсь распечатать отчет в формате PDF из своего приложения на этом конкретном принтере, я получаю следующую ошибку:
{System.Printing.PrintQueueException: PrintTicket provider failed to retrieve PrintCapabilities. Win32 error: -2147467259
at MS.Internal.Printing.Configuration.PTProvider.GetPrintCapabilities(MemoryStream printTicket)
at System.Printing.PrintTicketManager.GetPrintCapabilitiesAsXml(PrintTicket printTicket)
at System.Printing.PrintTicketManager.GetPrintCapabilities(PrintTicket printTicket)
at System.Printing.PrintQueue.GetPrintCapabilities(PrintTicket printTicket)
at System.Windows.Controls.PrintDialog.UpdatePrintableAreaSize()
at System.Windows.Controls.PrintDialog.get_PrintableAreaWidth()
at PulmOne.MiniBox2.Reporting.Controls.ReportProcessor.GetPrintableArea(Size& pageSize, Rect& printableArea)
at PulmOne.MiniBox2.Reporting.Controls.ReportProcessor.<GetPageContentsAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PulmOne.MiniBox2.Reporting.Controls.ReportProcessor.<GetDocumentAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PulmOne.MiniBox2.Reporting.Controls.ReportProcessor.<GenerateDocumentAsync>d__c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PulmOne.MiniBox2.ReportsWpf.ReportWindow.<OnWindowLoaded>d__d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)}
Я знаю, что проблема в этой строке кода:
{var dialog = new PrintDialog();
pageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);}
Есть ли способ решить эту проблему, чтобы он работал на всех принтерах?
Спасибо!