Is it possible to determine where the print job originated from?
I want to only perform my custom logic when the "publish" button is pressed, not when printing normally.
Determine print job origination
Moderator: Phil Barton
Re: Determine print job origination
When creating a print job handler, you can investigate the Properties of the IPrintJob object itself. There will be an entry keyed by Targets which provides the information you're looking for. Our default print job handlers all examine this value as they execute to selectively choose whether or not to actually do anything of interest (same thing you're trying to do).
For example:
For example:
Code: Select all
class MyPrintJobHandler : PrintJobHandler
{
protected override PrintJobHandlerResult OnProcess( IPrintJob printJob )
{
// get the string that represents the enumeration value for the target we're interested in
string publishTarget = Enum.GetName( typeof( PrintJobTarget ), PrintJobTarget.Publish );
// see if the target we're interested in is one of the specified targets in the print job
if ( ( printJob.Properties[PrintJobProperty.Targets] as List<String> ).Contains( publishTarget ) )
{
// do something
}
return PrintJobHandlerResult.Continue;
}
}
Re: Determine print job origination
Just what I was looking for, thanks