Using XPSDrv Print Drivers To Extend Windows Print Functionality Feng Yuan Technical Lead –...
-
Upload
phyllis-mccoy -
Category
Documents
-
view
217 -
download
0
Transcript of Using XPSDrv Print Drivers To Extend Windows Print Functionality Feng Yuan Technical Lead –...
Using XPSDrv Print Drivers Using XPSDrv Print Drivers To Extend Windows Print To Extend Windows Print FunctionalityFunctionality
Feng YuanFeng YuanTechnical Lead – DevelopmentTechnical Lead – DevelopmentDigital Documents Platform Digital Documents Platform and Solutionsand Solutions
AgendaAgenda
Filter Pipeline ExtensibilityFilter Pipeline Extensibility
Extensibility ScenariosExtensibility ScenariosAdvanced ColorAdvanced Color
ConfigurationConfiguration
NotificationsNotifications
Sample Filter WalkthroughsSample Filter Walkthroughs
Assumes familiarity with XPSDrv architecture and interfacesAssumes familiarity with XPSDrv architecture and interfaces
Filter Pipeline ExtensibilityFilter Pipeline Extensibility
The filter pipeline is designed for modular The filter pipeline is designed for modular and extensible IHV/ISV implementationsand extensible IHV/ISV implementations
Primary extensibility pointsPrimary extensibility pointsGeneric filtersGeneric filters
Configuration DLL Configuration DLL New DrvDocumentEvents eventsNew DrvDocumentEvents events
PrintTicket control PrintTicket control
Filter service publishingFilter service publishing
NotificationNotification
Custom Inter Filter Communicators (IFC)Custom Inter Filter Communicators (IFC)
Extensibility Scenario OverviewExtensibility Scenario Overview
Scenario: Advanced ColorScenario: Advanced Color
Windows Photo Gallery prints Windows Media Photo image Windows Photo Gallery prints Windows Media Photo image to XPSDrv print driver for 8-color inkjet photo printerto XPSDrv print driver for 8-color inkjet photo printer
Scenario: Advanced ColorScenario: Advanced Color
XPS Documents support high dynamic range, XPS Documents support high dynamic range, wide gamut vector and image contentwide gamut vector and image content
Using system services, filters can process rich Using system services, filters can process rich color data to best match printed output to user color data to best match printed output to user intent and device capabilitiesintent and device capabilities
Windows Color System (WCS) – Enables extensive Windows Color System (WCS) – Enables extensive color conversioncolor conversion
Windows Imaging Components (WIC) – Image Windows Imaging Components (WIC) – Image format support for Windows Media Photo and other format support for Windows Media Photo and other XPS image formatsXPS image formats
PrintTicket – Supports an array of color processing PrintTicket – Supports an array of color processing keywords to enable consistent and unambiguous keywords to enable consistent and unambiguous color control between app and devicecolor control between app and device
Scenario: Advanced ColorScenario: Advanced Color
Data FlowData FlowWindows Photo Gallery allows user selection Windows Photo Gallery allows user selection of print settingsof print settings
MXDW driver encapsulates Windows Media MXDW driver encapsulates Windows Media Photo image and print settings (as PrintTicket) Photo image and print settings (as PrintTicket) in XPS Documentin XPS Document
Filter process XPS file, decoding/transforming Filter process XPS file, decoding/transforming image, saving image to JPG formatimage, saving image to JPG format
Advanced Color FilterAdvanced Color Filter
Color Filter: Main MethodColor Filter: Main Method
HRESULT CColorFilter::StartOperation(void) { HRESULT hr = SetupColorTransform(L“SetupColorTransform(L“wsRGB.cdmpwsRGB.cdmp")"); CComPtr<IUnknown> pUnk;
while (SUCCEEDED(hr = m_pProvider->GetXpsPart(&pUnk)GetXpsPart(&pUnk))) { CComPtr<IXpsDocument> pXD; CComPtr<IFixedPage> pFP;
if (SUCCEEDED(pUnk.QueryInterface(&pXD))) { hr = m_pConsumer->SendXpsDocument(pXD); } else if ... else if (SUCCEEDED(pUnk.QueryInterface(&pFP)QueryInterface(&pFP))) { hr = ProcessFixedPage(pFP)ProcessFixedPage(pFP); hr = m_pConsumer->SendFixedPage(pFP)SendFixedPage(pFP); } } m_pConsumer->CloseSender(); m_pPrintPipeManager->FilterFinished(); DeleteColorTransform(m_hColorTrans)DeleteColorTransform(m_hColorTrans); return hr;}
Color Filter: Setup TransformationColor Filter: Setup Transformation
HPROFILE OpenColorProfile(const WCHAR * pszProfileName) { PROFILE profile = { PROFILE_FILENAME, (PVOID) pszProfileName, (DWORD) (wcslen(pszProfileName) * sizeof(WCHAR)) };
return WcsOpenColorProfile(&profile, NULL, NULL, PROFILE_READ,WcsOpenColorProfile(&profile, NULL, NULL, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);FILE_SHARE_READ, OPEN_EXISTING, 0);}
HRESULT SetupColorTransform(const WCHAR * pszDestProfileName){ HRESULT hr = S_OK; HPROFILE hProfile[2]; hProfile[0] = OpenColorProfile(L"wscRGB.cdmp"); hProfile[1] = OpenColorProfile(pszDestProfileName);
DWORD intents = INTENT_ABSOLUTE_COLORIMETRIC; m_hColorTrans = CreateMultiProfileTransform(hProfile, 2, &intents, 1,CreateMultiProfileTransform(hProfile, 2, &intents, 1, WCS_ALWAYS | BEST_MODE, INDEX_DONT_CARE)WCS_ALWAYS | BEST_MODE, INDEX_DONT_CARE);
CloseColorProfile(hProfile[0]); CloseColorProfile(hProfile[1]); return hr;}
Color Filter: Page ProcessingColor Filter: Page Processing
HRESULT CColorFilter::ProcessFixedPage(IFixedPage* pFP){ HRESULT hr = S_OK; CComPtr<IPrintWriteStream> pWriter;
if (SUCCEEDED(hr = pFP->GetWriteStream(&pWriter)GetWriteStream(&pWriter))) { CComPtr<IPrintReadStream> pReader;
if (SUCCEEDED(hr = pFP->GetStream(&pReader)GetStream(&pReader))) { CXmlFilter filter(pWriter, pReader)CXmlFilter filter(pWriter, pReader); // XML filter
while (filter.GetToken()filter.GetToken()) if (wcscmp(filter.m_token, L"ImageSource") == 0wcscmp(filter.m_token, L"ImageSource") == 0) { filter.GetToken(); // = filter.GetToken(); // URI for ImageSource ConvertImage(filter.m_token, filter.m_tokenlen, ConvertImage(filter.m_token, filter.m_tokenlen, COUNTOFCOUNTOF(filter.m_token)(filter.m_token), pFP), pFP); } } } pWriter->Close(); } return hr;}
Color Filter: Transform ImageColor Filter: Transform Image
HRESULT ConvertWriteImage(pStream, imageUri, pFixedPage){ HRESULT hr = S_OK; CComPtr<IUnknown> pRead; CComPtr<IPartImage> pImagePart; CComPtr<IPrintReadStream> pImageStream; if (SUCCEEDED(hr = pFixedPage->GetPagePart(imageUri, &pRead)pFixedPage->GetPagePart(imageUri, &pRead)) && SUCCEEDED(hr = pRead.QueryInterface(&pImagePart)) && SUCCEEDED(hr = pImagePart->GetStream(&pImageStream)pImagePart->GetStream(&pImageStream))) { CImage src; CImage dst; CPrintStream2IStream readStream(pImageStream, NULL); hr = src.Load(& readStream, m_pImagingFactory)src.Load(& readStream, m_pImagingFactory); hr = dst.Create(src.m_Width,src.m_Height,BM_dst.Create(src.m_Width,src.m_Height,BM_BGRBGRTRIPLETS)TRIPLETS);
TranslateBitmapBits(m_hColorTrans, src.m_pBuffer, src.m_icmFormat, TranslateBitmapBits(m_hColorTrans, src.m_pBuffer, src.m_icmFormat, src.m_Width, src.m_Height, src.m_Stride,src.m_Width, src.m_Height, src.m_Stride, dst.m_pBuffer, dst.m_pBuffer, dst.m_icmFormat, dst.m_Stride, dst.m_icmFormat, dst.m_Stride, NULL, NULL)NULL, NULL);
CPrintStream2IStream writeStream(NULL, pStream); hr = dst.Save(& writeStream, m_pImagingFactory)dst.Save(& writeStream, m_pImagingFactory); } return hr;}
Scenario: ConfigurationScenario: Configuration
During printing, XPSDrv configuration module optimizes During printing, XPSDrv configuration module optimizes PrintTicket settings and provides additional services to PrintTicket settings and provides additional services to XPSDrv filtersXPSDrv filters
Scenario: ConfigurationScenario: Configuration
The XPSDrv architecture supports the The XPSDrv architecture supports the ability to customize the configuration data ability to customize the configuration data and offer additional configuration servicesand offer additional configuration services
DrvDocumentEvents – Using new document DrvDocumentEvents – Using new document events, XPSDrv configuration modules can events, XPSDrv configuration modules can pre-process PrintTicket setting sent by pre-process PrintTicket setting sent by Windows Presentation Foundation Windows Presentation Foundation (WPF) applications(WPF) applications
Filter Services – The configuration module Filter Services – The configuration module can publish helper services for use at can publish helper services for use at print time by filtersprint time by filters
Scenario: ConfigurationScenario: Configuration
Example Data FlowExample Data FlowUser prints from a WPF applicationUser prints from a WPF application
DocumentEvents are intercepted by the DocumentEvents are intercepted by the configuration module and PrintTickets are configuration module and PrintTickets are added or modifiedadded or modified
When filters are processing the XPS file, When filters are processing the XPS file, the filter queries a configuration service the filter queries a configuration service to assist in constraint resolutionto assist in constraint resolution
Configuration ArchitectureConfiguration Architecture
Configuration ModuleConfiguration Module
DOCEVENT_FILTER * p = (DOCEVENT_FILTER*) pvOut;
switch (iEsc) { case DOCUMENTEVENT_DOCUMENTEVENT_XPS_XPS_QUERYFILTERQUERYFILTER: if (p->cElementsAllocated >= 7) { p->aDocEventCall[0] = DOCUMENTEVENT_XPS_DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPREADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPRE; p->aDocEventCall[1] = DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPOSTDOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPOST; ... p->cElementsReturned = 7; } else { p->cElementsNeeded = 7; } break;
case DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPREDOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPRE: *((PrintPropertiesCollection **) pvOut) = ReplacePT((PrintPropertiesCollection *) pvIn); break;
case DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPOSTDOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPOST: DeleteCollection(*((PrintPropertiesCollection **) pvIn)); break;}
Configuration FilterConfiguration Filter
HRESULT STDMETHODCALLTYPE StartOperation(VOID){ HRESULT hr; CComPtr<IPartPrintTicket> pPrintTicket;
while (SUCCEEDED(hr = m_pProvider->GetXpsPart(&pUnk)) { CComPtr<IXpsDocument> pXD; CComPtr<IFixedDocumentSequence> pFDS;
if (SUCCEEDED(pUnk.QueryInterface(&pXD))) { hr = m_pConsumer->SendXpsDocument(pXD); } else if (SUCCEEDED(pUnk.QueryInterface(&pFDS))) { if (pPrintTicket == NULL) { pFDS->GetPrintTicket(& pPrintTicket);pFDS->GetPrintTicket(& pPrintTicket); } hr = m_pConsumer->SendFixedDocumentSequence(pFDS); } ... }
AddPage(pPrintTicket); ... return hr;}
Configuration FilterConfiguration FilterHRESULT CConfigurationFilter::AddPage(IPartPrintTicket * pPrintTicket){ CComPtr<IFixedPage> pNewPage; CComPtr<IPrintWriteStream> pNewPageMarkupStream; CComPtr<IPartFont> pNewFont; CComPtr<IPrintWriteStream> pNewFontStream; m_pConsumer->GetNewEmptyPart(L"newpage.xaml", IID_IFixedPage, reinterpret_cast<void **>(&pNewPage), &pNewPageMarkupStream);
m_pConsumer->GetNewEmptyPart(L"new.ttf", IID_IPartFont, reinterpret_cast<void **>(&pNewFont), &pNewFontStream);
AddFontToPage(L"new.ttf", pNewFont, pNewFontStream, pNewPage); CComPtr<IPrintReadStream> ptStream; pPrintTicket->GetStream(& ptStream);
AddTextToPage(pNewPageMarkupStream, ptStream, m_pCoreHelper, "new.ttf"); return S_OK;}
Configuration FilterConfiguration Filter
HRESULT AddTextToPage(IPrintWriteStream *pPageMarkupStream, IPrintReadStream * ptStream, IPrintCoreHelperUni * pPrintHelper, const char * pFont){ CXpsWriter writer(pPageMarkupStream); writer.Write("<FixedPage Width=\"816\" Height=\"1056\" xmlns=" "\"http://schemas.microsoft.com/xps/2005/06\" xml:lang=\"en-US\">"); { CPrintTicketSaxHandler sax(writer, pFont, black); CComPtr<ISAXXMLReader> pSaxRdr; pSaxRdr.CoCreateInstance(CLSID_SAXXMLReader60); pSaxRdr->putContentHandler(& sax); pfp::PrintReadStreamToSeqStream reader(ptStream); pSaxRdr->parse(CComVariant(& reader)); } { CComPtr<IStream> pStream; pPrintHelper->CreateDefaultGDLSnapshot(0, & pStream); CGDLSaxHandler sax(writer, pFont, black); CComPtr<ISAXXMLReader> pSaxRdr; pSaxRdr.CoCreateInstance(CLSID_SAXXMLReader60); pSaxRdr->putContentHandler(& sax); pSaxRdr->parse(CComVariant(pStream); } return writer.Write("</FixedPage>");}
Scenario: NotificationsScenario: Notifications
While processing a print job, a filter sends async While processing a print job, a filter sends async notifications to a custom status monitornotifications to a custom status monitor
Scenario: NotificationsScenario: Notifications
The hierarchy of XPS Documents and The hierarchy of XPS Documents and the modular nature of XPSDrv filters the modular nature of XPSDrv filters facilitate incremental process that can facilitate incremental process that can be communicated using system servicesbe communicated using system services
Async Notification – The Windows Vista Async Notification – The Windows Vista spooler includes an async notificationspooler includes an async notificationengine for communication and UI messagesengine for communication and UI messages
XPS IFC – The structured nature of theXPS IFC – The structured nature of theXPS Document and the XPS Inter-filter XPS Document and the XPS Inter-filter Communicator identify key steps in Communicator identify key steps in document processingdocument processing
Scenario: NotificationsScenario: Notifications
Example Data FlowExample Data FlowAs an XPS Document is rendered in filters, As an XPS Document is rendered in filters, rendering progress is communicated through rendering progress is communicated through notification events dispatched by the filternotification events dispatched by the filter
Notification ArchitectureNotification Architecture
Notification FilterNotification FilterSTDMETHODIMP XpsFilter::InitializeFilter( __in IInterFilterCommunicator *pIfc, __in IPrintPipelinePropertyBag *pIPropertyBag, __in IPrintPipelineManagerControl *pIPipelineControl ){ ...
VARIANT var; VariantInit(&var);
pIPropertyBag->GetProperty(XPS_FP_PROGRESS_REPORT, &var);
Tools::SmartPtr<IUnknown> pUnk = V_UNKNOWN(&var); VariantClear(&var);
pUnk->QueryInterface(IID_IPrintPipelineProgressReport, reinterpret_cast<void **>(&m_pProgressReport));
...}
Notification FilterNotification FilterHRESULT XpsFilter::ProcessFixedDoc(__in void *pVoid){ Tools::SmartPtr<IFixedDocument> pIFixedDocument; pIFixedDocument.Attach(static_cast<IFixedDocument *>(pVoid)); HRESULT hRes = m_pXpsConsumer->SendFixedDocument(pIFixedDocument);
if (SUCCEEDED(hRes)) { m_pProgressReport->ReportProgress(XpsJob_FixedDocumentAdded); }
return hRes;}
HRESULT XpsFilter::ProcessFixedPage(__in void *pVoid){ Tools::SmartPtr<IFixedPage> pIFixedPage; pIFixedPage.Attach(static_cast<IFixedPage *>(pVoid)); HRESULT hRes = m_pXpsConsumer->SendFixedPage(pIFixedPage);
if (SUCCEEDED(hRes)) { m_pProgressReport->ReportProgress(XpsJob_FixedPageAdded); }
return hRes;}
Call To ActionCall To Action
Test for compatibility now!Test for compatibility now!Test the GDI Print Path, XPS Print PathTest the GDI Print Path, XPS Print Pathand compatibility pathsand compatibility paths
Report problems immediatelyReport problems immediately
Plan for XPSDrv supportPlan for XPSDrv supportHost-based printersHost-based printers
Pass-through XPSDrv drivers for XPS-Pass-through XPSDrv drivers for XPS-capable devices (direct consumption)capable devices (direct consumption)
Start implementation nowStart implementation nowAim for Windows Vista launch availabilityAim for Windows Vista launch availability
Call To ActionCall To Action
Understand your company logo goals and review Understand your company logo goals and review new logo requirementsnew logo requirements
Basic and PremiumBasic and Premium
At WinHECAt WinHECPractice driver dev and testing skills in XPS Printing hands on labsPractice driver dev and testing skills in XPS Printing hands on labs
Ask the Experts at lunch todayAsk the Experts at lunch today
Visit the Microsoft Pavilion to see XPS demos Visit the Microsoft Pavilion to see XPS demos
Read XPSDrv Print Drivers and the Windows Color System on Read XPSDrv Print Drivers and the Windows Color System on http://www.microsoft.com/whdc/device/print/default.mspx http://www.microsoft.com/whdc/device/print/default.mspx
Attend related sessionsAttend related sessionsPRI050 Inside Printer Installation on Windows VistaPRI050 Inside Printer Installation on Windows Vista
PRI039 Using the Windows Color System in Device DriversPRI039 Using the Windows Color System in Device Drivers
PRI077 Print Driver and XPSDrv Testing in Windows VistaPRI077 Print Driver and XPSDrv Testing in Windows Vista
PRI019 Developing XPSDrv Print DriversPRI019 Developing XPSDrv Print Drivers
PRI115 Windows Media Photo: A New Format for PRI115 Windows Media Photo: A New Format for End-to-End Digital ImagingEnd-to-End Digital Imaging
Additional ResourcesAdditional Resources
Technical adviceTechnical advice
WDK and SDK WDK and SDK
OnlineOnlineXPS Portal http://www.microsoft.com/xps, links to relevant blogs, white XPS Portal http://www.microsoft.com/xps, links to relevant blogs, white papers, specs papers, specs
WHDC Printing documents WHDC Printing documents http://www.microsoft.com/whdc/device/print/default.mspx http://www.microsoft.com/whdc/device/print/default.mspx
WHDC Color documentsWHDC Color documentshttp://www.microsoft.com/whdc/device/display/color/default.mspx http://www.microsoft.com/whdc/device/display/color/default.mspx
Windows Digital Documents Platform Team Newsletter Windows Digital Documents Platform Team Newsletter https://profile.microsoft.com/RegSysProfileCenter/subscriptionwizard.aspxhttps://profile.microsoft.com/RegSysProfileCenter/subscriptionwizard.aspx?wizid=77d9786e-9500-40a4-ba20-a4c7504d83ca&lcid=1033 ?wizid=77d9786e-9500-40a4-ba20-a4c7504d83ca&lcid=1033
XPSinfo @ microsoft.comXPSinfo @ microsoft.com
Prninfo @ microsoft.comPrninfo @ microsoft.com
mscolor @ microsoft.commscolor @ microsoft.com
© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,
it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.