microsoft / microsoft/Windows-driver-samples

Retrieving PrintTicket for shared XPS driver failes (returns PrintTicket of local computer)

Open
#362 4 comments 0 reactions 1 assignee Claimed by @DavidKanz View on GitHub
bug
Dominant language
C
Stars
7.8k
Forks
5k
Avg merge
3d 17h
Merged PRs (30d)
7

Description

When retrieving the PrintTicket from a shared XPS v4 driver, you get the PrintTicket of the local computer and not of the computer who printed to the shared driver.

The IPrintPipelinePropertyBag contains the incorrect information.
The user can be found when parsing the xps datastream itself.

Either this is a bug, or documentation should be improved as it is not clear then what we are doing wrong.

```
__override STDMETHODIMP StreamFilter::InitializeFilter(
_In_ IInterFilterCommunicator *pIFilterCommunicator,
_In_ IPrintPipelinePropertyBag *pIPropertyBag,
_In_ IPrintPipelineManagerControl *pIPipelineControl
){

m_JobInfo = new JobInformation(pIPropertyBag);
}

void JobInformation::SavePrintTicket(CString outputFolder)
{
SafeVariant varUserPrintTicket;
VariantInit(&varUserPrintTicket);
THROW_ON_FAILED_HRESULT(m_pIPropertyBag->GetProperty(XPS_FP_USER_PRINT_TICKET, &varUserPrintTicket));
IUnknown_t pUnk = varUserPrintTicket.punkVal;

IPrintReadStreamFactory_t pStreamFactory;
THROW_ON_FAILED_HRESULT(pUnk.QueryInterface(&pStreamFactory));

//
// Get the default user Print Ticket stream
// and wrap it in an IStream
//
IPrintReadStream_t pUserPrintTicketStream;
THROW_ON_FAILED_HRESULT(pStreamFactory->GetStream(&pUserPrintTicketStream));

DumpPrintTicket(pUserPrintTicketStream, outputFolder);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.