1

I have created a simple app for opening, viewing and printing PDF files. I want my app to be able to handle when a user right-clicks a PDF in explorer and selects 'print'.

My app is registered as the default handler for PDF files.

So, in short it should:

  1. Open the application
  2. Open the file
  3. Send print job to users default printer
  4. Close the app

I can handle the opening, loading, printing and quitting no problem at all. I just don't know how to make my app aware that it has been triggered using this context sensitive 'print' option in explorer. I thought it would just be sent as an additional parameter, but I can't seem to trap it.

Any ideas?

aybe
  • 15,516
  • 9
  • 57
  • 105
Si Stone
  • 121
  • 2
  • 12
  • How do you have the *Print* context menu item configured? That's going to determine how you handle it, but you've not included that information in your post. If your app is the default handler for PDF files, then it's your app that set up (and will receive) that command. How did you set it up to call your app? – Ken White Apr 02 '19 at 21:53

1 Answers1

1

Let's see how printing is handled by Acrobat DC:

Microsoft Windows [Version 10.0.17763.316]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Aybe>assoc .pdf
.pdf=AcroExch.Document.DC

Leads us to:

enter image description here

So basically they invoke the app with special switches that you can read more about here:

Adobe Reader Command Line Reference

You can also see similar examples in MSDN:

https://learn.microsoft.com/en-us/windows/desktop/shell/fa-verbs

In short:

  • make your application handle command-line switches for such situation
  • ensure that these switches are used by the registry entry
aybe
  • 15,516
  • 9
  • 57
  • 105