Я хочу создать приложение для принтера UWP для настройки виртуального принтера, который я затем могу выбрать из диалога Windows Print, следуя руководству по дизайну приложения для печати как можно более хорошего. alt = "отсутствующий виртуальный принтер" src = "https://i.sstatic.net/ikzmt3j8.png"/>
Я никогда не делал этого раньше (Driver/PSA -приложение), так что это совершенно новое для меня, и просто не смущает меня. Руководство по дизайну приложений поддержки может быть одной из худших и самых запутанных документаций, которые я когда -либо видел. На данный момент, чтобы убедиться, что я не удерживаю какую-либо важную информацию от вас < /p>
Здесь мы идем: < /p>
h3> app.xaml
< /code>
Aapp.xaml.cs
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Graphics.Printing.PrintSupport;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace PrintingApp
{
///
/// Provides application-specific behavior to supplement the default class.
///
sealed partial class App : Application
{
Deferral settingsDeferral;
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.PrintSupportSettingsUI)
{
// Get the activation arguments
var settingsEventArgs = args as PrintSupportSettingsActivatedEventArgs;
PrintSupportSettingsUISession settingsSession = settingsEventArgs.Session;
// Take deferral
this.settingsDeferral = settingsEventArgs.GetDeferral();
// Create root frame
var rootFrame = new Frame();
// Choose the page to be shown based upon where the application is being launched from
switch (settingsSession.LaunchKind)
{
case SettingsLaunchKind.UserDefaultPrintTicket:
{
// Show settings page when launched for default printer settings
rootFrame.Navigate(typeof(DefaultSettingsView), settingsSession);
}
break;
case SettingsLaunchKind.JobPrintTicket:
{
// Show settings page when launched from printing app
rootFrame.Navigate(typeof(MainPage), settingsSession);
}
break;
}
Window.Current.Content = rootFrame;
}
}
internal void ExitSettings()
{
settingsDeferral.Complete();
}
}
}
< /code>
функциональный
PrintingApp
CrazyEight
Assets\StoreLogo.png
< /code>
printerpdc1.xml (build action = content и copy в output directory = всегда) < /h3>
617e6418-6847-4fa1-bec6-3a3668d09f6d
printsupportworkflowbackgroundtask
Другие задачи имеют только taskinstance.getDeferral ().using Windows.ApplicationModel.Background;
using Windows.Graphics.Printing.PrintSupport;
using Windows.Graphics.Printing.Workflow;
namespace PrintingApp.Tasks
{
///
/// Background-Task für den virtuellen Drucker-Workflow.
///
public sealed partial class PrintSupportWorkflowBackgroundTask : IBackgroundTask
{
BackgroundTaskDeferral taskDeferral;
public void Run(IBackgroundTaskInstance taskInstance)
{
// Take Task Deferral
taskDeferral = taskInstance.GetDeferral();
var jobTriggerDetails = taskInstance.TriggerDetails as PrintWorkflowJobTriggerDetails;
// This registers the virtual printer for the app
var workflowBackgroundSession = jobTriggerDetails.PrintWorkflowJobSession as PrintWorkflowJobBackgroundSession;
// Register for events
workflowBackgroundSession.JobStarting += this.OnJobStarting;
workflowBackgroundSession.PdlModificationRequested += this.OnPdlModificationRequested;
// Start Firing events
workflowBackgroundSession.Start();
taskDeferral.Complete();
}
private void OnPdlModificationRequested(PrintWorkflowJobBackgroundSession sender, PrintWorkflowPdlModificationRequestedEventArgs args)
{
// TODO
}
private void OnJobStarting(PrintWorkflowJobBackgroundSession session, PrintWorkflowJobStartingEventArgs args)
{
using (args.GetDeferral())
{
// Call SetSkipSystemRendering to skip conversion for XPS to PDL, so that PSA can directly manipulate the XPS file.
args.SetSkipSystemRendering();
}
}
}
}
< /code>
csproj < /h3>
Debug
x86
{BFDA5F9B-D16A-4460-8F23-D55AACBEA9EA}
AppContainerExe
Properties
PrintingApp
PrintingApp
en-US
UAP
Подробнее здесь: https://stackoverflow.com/questions/796 ... showing-up
UWP - приложение для поддержки печати - виртуальный принтер не отображается ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
UWP - приложение для поддержки печати - виртуальный принтер не отображается
Anonymous » » в форуме C# - 0 Ответы
- 1 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как заставить несовместимый встроенный принтер «действовать» как совместимый принтер?
Anonymous » » в форуме Android - 0 Ответы
- 52 Просмотры
-
Последнее сообщение Anonymous
-