Developing XPSDrv Print Drivers Felix Maxa Software Design Engineer Digital Documents Platform and Solutions Feng Yue Development Lead Digital Documents Platform and Solutions.

Download Report

Transcript Developing XPSDrv Print Drivers Felix Maxa Software Design Engineer Digital Documents Platform and Solutions Feng Yue Development Lead Digital Documents Platform and Solutions.

Developing XPSDrv
Print Drivers
Felix Maxa
Software Design Engineer
Digital Documents Platform and Solutions
Feng Yue
Development Lead
Digital Documents Platform and Solutions
Agenda
XPSDrv Filter Pipeline
XPSDrv Configuration
GPD/PPD-Only Configuration
Unidrv/PScript5 Plug-in Configuration
XPSDrv Setup and Installation
XPSDrv Logo Requirements
Assumes basic familiarity with XPSDrv
XPSDrv Overview
New print driver model in Window Vista
XPS Document format is the spool file
Advanced color and graphic support
Application content preserved to driver or device
Defines an extensible filter pipeline
Consolidated design for plug-ins
Shared common functionality
Allows flexible allocation of rendering between driver
and device (scalable consumption)
Compatibility with Win32 and Windows
Presentation Foundation (WPF) applications
XPSDrv Filter Pipeline
Felix Maxa
Software Design Engineer
Digital Documents Platform and Solutions
XPSDrv Filter
Pipeline Architecture
Provided by
Microsoft
Win32 App
ISV
WPF App
IHV
Filter Pipeline
Config Module/
Plug-in
Conversion
Render Module
XPS
Version 3
Driver
Application
Process
Filter Pipeline
Manager
FP
Config
XML
Spooler
Process
Property
Bag
Filter 1
Filter N
Filter Pipeline Process
Print Paths
Provided by
Microsoft
SPOOL
FILE
ISV
IHV
Filter Pipeline Process
Spooler
Process
Filter Pipeline
Filter Pipeline
Manager
Filter 1
Print processor
GDI
Printer Driver
FP
Config
XML
Property
Bag
Filter N
Filter Pipeline Manager
The Filter Pipeline Manager (FPM)
is responsible for
Loading and initializing filters as described
by the filter configuration file to create the
filter pipeline
Managing the data between filters as the
print job is processed via the Inter-filter
Communicators (IFC)
Unloading filters when the print job is finished
Print Pipeline Filter
Configuration File
XML file that defines
Filter ordering – Simple ordering of
XML elements
Filter interfaces – Defined by XML attributes
Input/output formats for each filter – Defined
by XML elements
Potential for modification by IT Admins to
add filters
Be aware of functionality impact
Pipeline Config File Sample
<Filters>
<Filter dll
clsid
name
<Input guid
comment
<Output guid
comment
</Filter>
=
=
=
=
=
=
=
"WdkPipelineFilter.dll"
"{8267d291-6ddd-4972-a94e-3ce88149a1fa}"
"add simple page">
"{b8cf8530-5562-47c4-ab67-b1f69ecf961e}"
"IID_IXpsDocumentProvider"/>
"{4368d8a2-4181-4a9f-b295-3d9a38bb9ba0}"
"IID_IXpsDocumentConsumer"/>
<FilterServiceProvider dll = "providerA.dll"/>
<FilterServiceProvider dll = "providerB.dll"/>
</Filters>
Property Bag
Sharing data between
Filters
Pipeline manager and filters
Pairs (string
Examples
key, variant value)
("PrinterName",
("ProgressReport",
("PrinterHandle",
("UserSecurityToken",
("PrintJobId",
VARIANT_BSTR)
VARIANT_IUNKNOWN)
VARIANT_BYREF)
VARIANT_BYREF)
VARIANT_ULONG)
Filter Access To XPS Job
Stream
XPS high level interfaces
[0].piece
[0].piece
[1].last.piece
[0].piece
[1].last.piece
[0].piece
[1].last.piece
[0].last.piece
[0].piece
[1].piece
[2].last.piece
[0].piece
[1].last.piece
FONT-1
IMAGE-1
IMAGE-1
FONT-2
FONT-2
IMAGE-2
IMAGE-2
PT-1
FDS
FDS
FDS
FP
FP
Resources\99bc59ed.ODTTF\
Resources\8792381d.jpg\
Resources\8792381d.jpg\
Resources\6b2554d5.ODTFF\
Resources\6b2554d5.ODTFF\
Resources\42a30e86.jpg\
Resources\42a30e86.jpg\
Metadata\Job_PT.xml\
FixedDocumentSequence.fdseq\
FixedDocumentSequence.fdseq\
FixedDocumentSequence.fdseq\
Documents\1\Pages\3.fpage
Documents\1\Pages\3.fpage
XPS Filter Pipeline
IPrintPipelinePropertyBag
MS Pipeline component
ISV / IHV filter
Property Bag
P
XPS Part / interface
IXpsDocumentProvider
S
XPS
SPOOL
FILE
D
P
S
D
D
P
D
P
S
P
P
FILTER
P
P
FILTER
D
P
IXpsDocumentConsumer
Serialize
Flatten
XPS
Back to
spooler
XPS Filter Pipeline Notifications
MS Pipeline component
Property bag
ISV / IHV filter
XPS_FP_PROGRESS_REPORT
IPrintPipelineProgressReport
Get & Delete property
P
XPS_FP_PRINTER_NAME
string
S
D
P
P
XPS
FILTER
Serialize
Flatten
XPS
Back to
spooler
XPS Part / interface
XPS Render Filter Notifications
MS Pipeline component
Property bag
XPS_FP_PROGRESS_REPORT
IPrintPipelineProgressReport
ISV / IHV filter
Get & Delete property
P
XPS Part / interface
XPS_FP_PRINTER_NAME
string
S
D
P
P
XPS
to
PDL
FILTER
Stream
Buffer
IPrintWriteStream
Back to
spooler
XPS Document Filter Interfaces
Filters can
Read and write Page markup
Read content for other parts
Create new parts and associate with pages
Create new documents and pages
Delete relationships
Enumerate resources for page
Mix of XPS and Stream based filters
The filter pipeline manager takes care
of data conversion
The Filter Interface Definition
interface IPrintPipelineFilter : IUnknown
{
HRESULT
InitializeFilter(
[in]
IInterFilterCommunicator
[in]
IPrintPipelinePropertyBag
[in]
IPrintPipelineManagerControl
);
HRESULT
ShutdownOperation(
void
);
HRESULT
StartOperation(
void
);
}
*pICommunicator,
*pIPropertyBag,
*pIPipelineControl
Custom Filter Interfaces
<Filters>
<Filter dll
clsid
name
<Input
=
=
=
guid =
comment =
<Output guid =
provider =
dll =
</Filter>
"CustomFilterA.dll"
"{33b32cf3-954c-4dfd-a016-6f05303fe65b}"
"read stream - write custom">
"{4d47a67c-66cc-4430-850e-daf466fe5bc4}"
"IID_IPrintReadStream"/>
"{00000003-0000-0000-C000-000000000046}"
"{a6686ae8-909f-42ee-9377-6fc6c815df61}"
"CustInterfaceProvider.dll"/>
<Filter dll
clsid
name
<Input
<Output
"CustomFilterB.dll"
"{f761761d-5467-409a-adff-91460ba008d9}"
"read custom - write stream">
"{00000003-0000-0000-C000-000000000046}"/>
"{65bb7f1b-371e-4571-8ac7-912f510c1a38}"
"IID_IPrintWriteStream"/>
</Filter>
</Filters>
=
=
=
guid =
guid =
comment =
Custom Filter Interfaces
MS Pipeline component
ISV / IHV filter
P
XPS Part / interface
Provider
XPS
or
Stream
Filter
A
IUnknown
Filter
B
XPS
or
Stream
Filter Service Providers
Module which exports
HRESULT
DrvPopulateFilterServices(
__in IPrintPipelinePropertyBag
);
*pPropertyBag
Registered in the pipeline config
<FilterServiceProvider dll = “providerA.dll”/>
Access to configuration module functionality
and data from filters
Ex. IPrintCoreHelper
Interleaving
Page level interleaving
Resources first
Mark up first
Interleaved at certain piece size
For some devices, filter must help
Ensure resources are available when needed
Enables consumption by memory
constrained consumers
Use discard control
Send resources again
Interleaving In Config File
<Filter dll
clsid
<Input
<Output
guid
guid
<Interleaving
<Interleaving
<Interleaving
<Interleaving
<Interleaving
</Filter>
=
=
=
=
"TestFilter.dll"
"{e96f780a-5b6a-47d5-a433-fa0d4e52688d}"
"{b8cf8530-5562-47c4-ab67-b1f69ecf961e}"/>
"{4368d8a2-4181-4a9f-b295-3d9a38bb9ba0}"/>
mode="MarkupFirst" pieceSize="0"/>
mode="MarkupFirst" pieceSize="2000"/>
mode="ResourcesFirst" pieceSize="30900"/>
mode="MarkupFirst"/>
mode="ResourcesFirst"/>
Filter Recommendations
Filters should not spawn separate
processes or threads
If a separate process/thread is required for
a filter, the filter MUST properly manage the
process/thread lifetime
Stream filters – aware that not all data
is correctly interleaved
Filters must be robust to non-interleaved
and incorrectly interleaved content
Common Implementation
Challenges
COM apartment model
Driver packages – XML file changes
PnPUtil.exe
Debug help
System\CurrentControlSet\Control\Print
PipelineHostTimeout REG_DWORD miliseconds
PipelineDebugLog
REG_DWORD 0 or non-0
XPSDrv Configuration
Feng Yue
Development Lead
Digital Documents Platform and Solutions
XPSDrv Configuration
Architecture
Win32 App
Provided by
Microsoft
ISV
WPF App
IHV
XPSDrv Driver
Version 3 Driver
GPD
Unidrv Config
Module
Unidrv Plug-in
PPD
PScript5 Config
Module
PScript5 Plug-in
Monolithic
Config Module
Conversion
Render Module
Filter Pipeline
XPS
Filter 1
Config Module
Filter N
GPD/PPD-Only
Configuration
GPD/PPD-Only Config
GPD/PPD-only configuration is supported
for XPSDrv printer drivers
Smallest investment cost and short
development time
No customization of Unidrv/PScript5 behavior
No UI customization
Best suited for XPSDrv passthrough or
basic printer drivers
Primary changes are
Print Schema Mapping
XPSDrv Specific GPD/PPD Entries
GPD/PPD To Print Schema Map
Standard GPD/PPD keywords
automatically mapped to public Print
Schema equivalents
Example:
*Feature: PaperSize ->
<psf:Feature name=“psk:PageMediaSize”>
Non-standard keywords automatically
mapped to private device namespace
Example:
*Feature: IHVFoo ->
<psf:Feature name=“ns0001:IHVFoo”>
GPD/PPD To Print Schema Map
Windows Vista GPD/PPD parsers will recognize
new Print Schema mapping keywords
Specify IHV private namespace for automatically
mapped keyword
Specify mapping from non-standard keywords to Print
Schema equivalents
GPD Keywords
PrintSchemaPrivateNamespaceURI
PrintSchemaKeywordMap
PPD Keywords
MSPrintSchemaPrivateNamespaceURI
MSPrintSchemaKeywordMap
GPD/PPD XPSDrv Entries
New “Include” entry to reference XPSDrv
standard contents
msxpsinc.gpd
msxpsinc.ppd
Currently files include a new keyword to
specify XPSDrv printer driver
*IsXPSDriver?: TRUE
(msxpsinc.gpd)
*MSIsXPSDriver?: TRUE (msxpsinc.ppd)
Keyword must be present to properly recognize
XPSDrv drivers
GPD Sample File
*GPDFileVersion: "1.0"
*Include:
"StdNames.gpd”
*Include:
“MSXpsInc.gpd”
*%
*% IHV Private Namespace
*%
*PrintSchemaPrivateNamespaceURI:“http://www.ihv.com/
schema/2006”
*%
*% IHV Private Feature
*%
*Feature: IHVStapling {
*PrintSchemaKeywordMap: “JobStaple"
*Option: Enabled {
*PrintSchemaKeywordMap: “StapleTopLeft" }
*Option: Disabled {
*PrintSchemaKeywordMap: “None” }
}
Unidrv/PScript5
Plug-In Configuration
Unidrv/PScript5 Plug-In Config
Unidrv/PScript5 Plug-in allows full customization
of config module
Ability to modify, replace and add to system
PrintTicket/PrintCapabilities (PT/PC) processing
Ability to fully replace system UI
Non-trivial investment cost and development time
Suited for all types of XPSDrv drivers
Primary changes are
Plug-in PT/PC provider: IPrintOemPrintTicketProvider
Helper interface for Unidrv/PScript5 settings:
IPrintCoreHelper
XPSDrv document events and communicating
with filters
IPrintOemPrintTicketProvider
Enables plug-ins to customize PT/PC processing
Results of Unidrv/PScript5 processing will be passed to plug-in to
finalize processing
DECLARE_INTERFACE_(IPrintOemPrintTicketProvider,
IUnknown)
{
STDMETHOD(GetSupportedVersions)(…)
STDMETHOD(BindPrinter)(…)
STDMETHOD(PublishPrintTicketHelperInterface)(…)
STDMETHOD(QueryDeviceDefaultNamespace)(…)
STDMETHOD(ConvertPrintTicketToDevMode)(…)
STDMETHOD(ConvertDevModeToPrintTicket)(…)
STDMETHOD(CompletePrintCapabilities)(…)
STDMETHOD(ExpandIntentOptions)(…)
STDMETHOD(ValidatePrintTicket)(…)
};
IPrintCoreHelper
COM interface that enables plug-ins to read and set the
Unidrv and PScript5 private DEVMODE settings
Enables functional parity for full-UI replacement
DECLARE_INTERFACE_(IPrintCoreHelper, IUnknown)
{
// IUnknown methods skipped
STDMETHOD(CreateInstanceOfMSXMLObject)(…)
STDMETHOD(EnumConstrainedOptions)(…)
STDMETHOD(EnumFeatures)(…)
STDMETHOD(EnumOptions)(…)
STDMETHOD(GetOption)(…)
STDMETHOD(SetOptions)(…)
STDMETHOD(WhyConstrained)(…)
STDMETHOD(GetFontSubstitution)(…)
STDMETHOD(SetFontSubstitution)(…)
};
IPrintCoreHelper
Two derived interfaces provide Unidrv and PScript5
specific functionality
DECLARE_INTERFACE_(IPrintCoreHelperUni,
IPrintCoreHelper)
{
STDMETHOD(CreateDefaultGDLSnapshot)(…)
STDMETHOD(CreateGDLSnapshot)(…)
};
DECLARE_INTERFACE_(IPrintCoreHelperPS, IPrintCoreHelper)
{
STDMETHOD(GetGlobalAttribute)(…)
STDMETHOD(GetFeatureAttribute)(…)
STDMETHOD(GetOptionAttribute)(…)
};
XPSDrv Document Events
XPSDrv will use the existing
DrvDocumentEvent mechanism
When printing from Win32 apps, existing GDI events
will be used
When printing from WPF apps,
the following new XPS events will be used
DOCUMENTEVENT_XPS_QUERYFILTER
DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRE/POST
DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTPRE/POST
DOCUMENTEVENT_XPS_ADDFIXEDPAGEEPRE/POST
DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTSEQUENCEPRINTTICKETPRE
/POST
DOCUMENTEVENT_XPS_ADDFIXEDDOCUMENTPRINTTICKETPRE/POST
DOCUMENTEVENT_XPS_ADDFIXEDPAGEPRINTTICKETPRE/POST
DOCUMENTEVENT_XPS_CANCELJOB
Configuration Recommendations
For Unidrv/PScript5 drivers, provide
separate GPD/PPD for each filter
Contributes to the modularity of filters
Expose PT/PC keywords in the public
Print Schema
Where possible, map driver features to public
Print Schema keywords
Contributes to application use of features
Contributes to better synchronization of
driver and application settings
Setup And Installation
INF Changes
XPSDrv drivers need to make a series of
changes to be properly registered by
the spooler
CopyFiles
Must include Filter Pipeline configuration file
Needs
Must include XPSDRV.OEM install directive
Unidrv/PScript5 drivers must include
XPSGPD.OEM or XPSPPD.OEM
install directives
INF File Sample
[Manufacturer]
Microsoft
[Microsoft]
"XPSDrv Sample Driver" = INSTALL_XDSMPL_FILTERS
[INSTALL_XDSMPL_FILTERS]
CopyFiles=XPSDrvSample,ConfigPlugin,COLORPROFILES
DataFile=XDSmpl.GPD
Include=NTPRINT.INF
Needs=UNIDRV.OEM, XPSGPD.OEM, XPSDRV.OEM
ICMProfiles=xdwscRGB.cdmp
[XPSDrvSample]
xdsmpl-pipelineconfig.xml
...
Windows Logo
Program Requirements
Premium Logo Requirement
XPSDrv implementation is a requirement
for the Premium Logo for print and
multi-function devices
See DEV-PRNT-56 in the
Windows Logo Program
requirements for more information
Configuration Module
Logo Requirements
Must be a valid Version 3 printer driver
configuration module
Must support PrintTicket and
PrintCapabilities
All features configurable in the driver UI
Minimal set keywords are required for
basic functionality
Filter Pipeline
Logo Requirements
The XPSDrv driver must include a valid Filter
Pipeline Configuration File
Filters must conform to the rendering rules and
PrintTicket processing rules defined in the XML
Paper Specification
Filters must not have a dependency on the CLR
or the WinFX Runtime Components
Filters in the XPSDrv driver filter pipeline must
not display User Interface (UI) content
Call To Action
Test for compatibility now!
Test the GDI Print Path, XPS Print Path, and
compatibility print paths
Report problems immediately
Plan for XPSDrv support
Host-based printers
Pass-through XPSDrv drivers for
XPS-capable devices (direct consumption)
Start implementation now
Aim for Windows Vista launch availability
Call To Action
Review the Windows Vista Logo Program requirements
Basic and Premium
At WinHEC
Practice driver dev and testing skills in XPS Printing hands
on labs
Ask the Experts at lunch today
Visit the Microsoft Pavilion to see XPS demos
Read XPSDrv Print Drivers and the Windows Color System on
http://www.microsoft.com/whdc/device/print/default.mspx
Attend related sessions
PRI050 Inside Printer Installation on Windows Vista
PRI039 Using the Windows Color System in Device Drivers
PRI102 Using XPSDrv Print Drivers to Extend Windows
Print Functionality
PRI077 Print Driver and XPSDrv Testing in Windows Vista
Additional Resources
Technical advice
XPSinfo @ microsoft.com
Prninfo @ microsoft.com
Mscolor @ microsoft.com
WDK and SDK
Online
XPS Portal http://www.microsoft.com/xps
Links to relevant blogs, whitepapers, specs
WHDC Printing documents
http://www.microsoft.com/whdc/device/print/default.mspx
WHDC Color documents
http://www.microsoft.com/whdc/device/display/color/default.mspx
Windows Digital Documents Platform Team Newsletter
https://profile.microsoft.com/RegSysProfileCenter/subscriptionwizard.aspx
?wizid=77d9786e-9500-40a4-ba20-a4c7504d83ca&lcid=1033
© 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.