Determine print job origination

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
daniorg
Posts: 11
Joined: Thu Dec 02, 2010 11:14 am

Determine print job origination

Post by daniorg »

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.
Mark McKenna

Re: Determine print job origination

Post by Mark McKenna »

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:

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;
	}
}
daniorg
Posts: 11
Joined: Thu Dec 02, 2010 11:14 am

Re: Determine print job origination

Post by daniorg »

Just what I was looking for, thanks
Post Reply