Adding print ticket information to an XPS document

I have a pdf document that I need to convert to xps and add print tickets before sending to printer. I able to convert pdf to xps but don’t know how to add print tickets (or printing information) to the document before sending to the printer.

I need to be able to set the following:

  1. Input and output tray/bin
  2. Orientation (landscape or portrait)
  3. Color or black and white
  4. Duplex mode

In addition to these, is there a list of all items that I can set for the print job/ticket?

@imranmp

You can surely use the JobPrintTicket Class offered by Aspose.Page to achieve your requirements. In case you face any issues, please feel free to share with us.

Are there code examples that I can reference?

@imranmp

You can try following code to make your printer print an XPS document in duplex mode:

doc.JobPrintTicket = new JobPrintTicket(JobFeature.JobDuplexAllDocumentsContiguously.TwoSidedLongEdge);

or

doc.JobPrintTicket = new JobPrintTicket(JobFeature.JobDuplexAllDocumentsContiguously.TwoSidedShortEdge);

depending on the page flip method. Furthermore, a task has been logged in our issue tracking system to add code examples in the API documentation for this feature. We will let you know as soon as it is done. Please spare us some time.

I am using .Net and api reference for .Net seems to be missing Aspose.Page Product family | Aspose API References

How can I set specific InputBin? AutoSelect is the only option. Also what about setting orientation and color options? and what’s the difference between Job and Document features?

  XpsDocument doc = new XpsDocument(filePath);
	doc.JobPrintTicket = new JobPrintTicket(JobFeatures.JobDuplexAllDocumentsContiguously.TwoSidedLongEdge, JobFeatures.JobInputBin.AutoSelect);
	doc.JobPrintTicket = new JobPrintTicket(DocumentFeatures.DocumentDuplex.TwoSidedLongEdge, DocumentFeatures.DocumentInputBin.AutoSelect);

@imranmp

We are looking into this matter and will get back to you soon.

@imranmp

We are checking the issue of missing API references and will fix it soon.

As for specifying an InputBin feature, Aspose.Page basically provides an interface for constructing print tickets. So, AutoSelect was not designed as the only option available, but as the simplest version of the InputBin feature.

You can construct your own features (not just InputBin) referring to Print Schema - Win32 apps | Microsoft Learn. Or, more exactly, for example, JobInputBin - Win32 apps | Microsoft Learn. As for InputBin feature, it can be constructed like this:

document.JobPrintTicket.Add(new JobFeatures.JobInputBin(
                new Option("psk:optionName",
                    new Property("psk:propertyName1", new Value(propertyValueType1 /*see ValueType class consts*/, "propertyValue1")),
                    // ...
                    new Property("psk:propertyNameN", new Value(propertyValueTypeN /*see ValueType class consts*/, "propertyValueN")),
                    new ScoredProperty("psk:scoredPropertyName1", new Value(scoredPropertyValueType1 /*see ValueType class consts*/, "scoredPropertyValue1")),
                    // ...
                    new ScoredProperty("psk:scoredPropertyNameM", new Value(scoredPropertyValueTypeM /*see ValueType class consts*/, "scoredPropertyValueM"))
                )));

As for page orientation, there are corresponding constants in the Features.PageOrientation class. For example, document.JobPrintTicket.Add(Features.PageOrientation.Portrait);

As for color options, these feature must be constructed manually according to the Print Ticket Schema.

In fact there is no difference between particular features that could be found in both the JobFeatures and DocumentFeatures classes. But as the feature sets are different for jobs and documents, We grouped them into separate classes. So the features from JobFeatures are meant to be used in job print tickets, and the features from DocumentFeatures are meant to be used in document print tickets.

This print tickets interface is actually quite raw. We didn’t improve it much because it wasn’t considered a highly required feature. So maybe it’s time to get back to it. PAGENET-372 has been logged for this purpose.

As for examples in docs, yes, the article must be written. But it will take some time and we will let you know once the ticket is resolved.