Feng Yuan Principal Software Development Engineer Microsoft Corporation Raise awareness of XPS document performance issues Demonstrate how to measure XPS documents Demonstrate how to optimize XPS documents.
Download
Report
Transcript Feng Yuan Principal Software Development Engineer Microsoft Corporation Raise awareness of XPS document performance issues Demonstrate how to measure XPS documents Demonstrate how to optimize XPS documents.
Feng Yuan
Principal Software Development
Engineer
Microsoft Corporation
Raise awareness of XPS document
performance issues
Demonstrate how to measure
XPS documents
Demonstrate how to optimize
XPS documents
Performance issues with XPS documents
Metrics for XPS documents
XPS measuring tool
Optimizing XPS documents
FixedPage
Font
Image
Call To Action
Generation
Transmission
Archiving
Searching
Viewing
Printing
Discarding
Transmission
Zip container decoding
Stream decompression
Object model building
Document structure construction
Rendering
Conversion
Searching
Larger storage requirement
Larger network bandwidth requirement
Slower downloading
Slower viewing
Slower printing
Unable to view or print
XPS document size
Loading time
Memory consumption
Rendering time
Searching time
Container: Original size, compression,
number of streams, order of streams,
interleaving
Markup: Number of elements, number
of attributes, nesting of opacity, area of
opacity, sharing of objects
Image: Resolution, pixel format, file
format, compression
Font: Tables, glyphs
Common Package Parts
XPS Package Relationships
Core Properties
Thumbnail
Signature Origin
Signature
X509 Certificate
Required or
Recommended
Parts
Optional
Parts
Resources
Relationship
Fixed Document Sequence
Fixed Document
FixedPage
Document Structure
Thumbnail
Font
FixedPage
Image
Resource Dictionary
Type
Count
Original
Compressed
Ratio
fixedpage
453
116,521,006
5,912,474
95%
package.relationships
434
573,558
164,871
71%
properties
1
673
342
49%
fixeddocument
1
289,702
13,756
95%
20
1,647,572
576,144
65%
492
1,042,993
992,681
5%
fixeddocumentsequence
1
320
160
50%
documentstructure
1
179,194
13,154
93%
/[Content_Types]
1
1,023
331
68%
195,978
195,978
0%
1,410 120,452,019
7,869,891
93%
opentype
Image
ZIP Structure
Summary
Main contributor for long document
Compression ratio: 95%
500 elements for normal page
10K to million elements for complex page
Page
1.fpage
10.fpage
453.fpage
Summary
Size
1,690,254
530
237,266
116,521,006
Glyphs
57
0
352
87,179
Path
1,037
0
15
111,593
Image
1,994
0
0
11,653
OpacityMask
997
0
0
5,690
Main contributor for short document
Compression ratio: 40% to 90%
Larger document if not embeddable
Typeface
Size
CompSize
Elements
Char
Used
Original
Glyphs
Verdana Italic
60,668
21,765
3,287
76
893
Arial Bold
81,356
16,371
320
1[32]
1,674
Courier New Regular
71,824
41,569
19,896
104
1,318
MS Mincho Regular
209,844
19,532
4
38
17,807
Wingdings Regular
24,052
9,623
1
1[232]
226
Verdana Regular
73,020
29,075
49,436
99
893
Contributing to all documents
Compression ratio: 0% to 5%
Implementing non-embeddable text
Choose right size, format, compression
Image
Size CompSize Width Height Format Usage
thumbnail.jpeg 6,538
5,832 197
256
Bgr24
image_0.png
143
131
1
1
Bgra32
4
image_2.png
145
136
2
1
Bgra32
182
image_348.jpg 33,579
33,277 392
611
Bgr24
1
image_96.png 10,568
10,489 474
205 Indexed8
1
Color
206
black
2
121
Use simple syntax
Solid Color Brush: Fill=“#FFFFFF”
Path: Data=“M0,0 h100v100h-100z”
Use less costly representation
Single color image solid color
Same color gradient solid color
Image with same rows/columns single row/column
Remove non-visible elements
Empty path, glyph elements
Opacity=0, totally clipped, out of bound, totally covered
Remove default value/redundancy
Opacity, BidiLevel, TileMode, StyleSimulation, IsSideways
Clipping larger than elements, same as paper bounds
Canvas with single child, no attributes
Glyphs.Indices optional for simple mapping and layout
Remove redundant paths/points in path geometry
Reuse elements and attributes
Resource and remote resource dictionary
Brushes, MatrixTransform, Path, Glyphs, Canvas
Use RenderTransform to create more reusable parts
Remove default value/redundancy
Opacity, BidiLevel, TileMode, StyleSimulation,
IsSideways
Clipping larger than elements, same as paper bounds
Canvas with single child, no attributes
Glyphs.Indices optional for simple mapping and layout
Remove redundant paths/points in path geometry
Reuse elements and attributes
Resource and remote resource dictionary
Brushes, MatrixTransform, Path, Glyphs, Canvas
Use RenderTransform to create more reusable parts
Merge Glyphs/Path elements
Merge same size/font glyphs on the same line
Merge simple paths with the same stroking/filling
Merge tiled images
Replace simulated gradient fill with real gradient
More complex optimization
Brush algebra: (red, 0.5) * (red, 0.5) = (red, 0.75)
opacity1 * (rgb, opacity2) = (rgb, opacity1 * opacity2)
Selective rasterization
VisualBrush for hatching, stencils
<FixedPage.Resources> <ResourceDictionary>
<RadialGradientBrush x:Key="black" Center="0.5,0.5"
RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.2,0.2">
<RadialGradientBrush.GradientStops>
<GradientStop Color="#ff505050" Offset="0" />
<GradientStop Color="#e0080808" Offset="1" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
<PathGeometry x:Key="circle"
Figures="M0,-0.5 A0.5,0.5 0 1 1 0,0.5 A0.5,0.5 0 1 1 0,-0.5" />
<PathGeometry x:Key="grid33"
Figures="m0,0h2 M0,1h2 M0,2h2 M0,0v2 M1,0v2 M2,0v2" />
</ResourceDictionary> </FixedPage.Resources>
<Canvas RenderTransform="48, 0, 0, 48, 48, 48">
<Path Data="m0.5,0.5 h3 v3 h-3z" Fill="#E0C000" />
<Path Data="{StaticResource grid33}" Stroke="#000000“
StrokeThickness="0.03" RenderTransform="1, 0, 0, 1, 1, 1"/>
<Path Data="{StaticResource circle}" Fill="{StaticResource black}“
RenderTransform="0.9, 0, 0, 0.9, 1, 1"/>
</Canvas>
Subset fonts, preferably per document
Remove/replace barely used fonts
Substitute fonts when not embeddable
Share glyph bitmaps/outlines
Font tables of limited usage
GSUB, GPOS, kern
EBDT, hdmx, vdmx
Consider rearrange glyph indices
Vista, simkai.ttf, 28,562 glyphs, 11 mb
Subset with围棋, 183k, 55k compressed
hmtx 58k, loca 57k, vmtx 57k, glyf 690b
Convert to path geometry: 1148b+1260b
<PathGeometry x:Key="wood“ Figures="M173,-311 q23,-5
35,-5 12,0 19,7 7,7 -6,12 -13,5 -48,12 l0,70 30,2 46,11
17,8 12,23 -4,15 -17,11 -13,-5 -41,-33 0,70 -3,128 -2,57
-10,92 -8,35 -21,8 -13,-27 -6,-58 7,-32 12,-72 5,-40 5,122 -31,56 -56,87 -24,30 -56,53 -31,22 -3,-9 28,-32 58,84 31,-52 45,-98 l-49,9 q-22,2 -42,-8 -19,-11 13,-14
33,-4 90,-16 0,-49 -2,-85 -1,-36 -14,-55 -13,-19 21,-8
34,10 27,30 -7,20 -9,114 z" />
<Path Data="{StaticResource wood}" Fill="#C00000FF"
RenderTransform=“5 0 0 5 2000 2800" />
Share duplicated images (crc32)
Stitch banded images
Single color/same row/same column image
Pick the right size, trim image
Pick the right color depth
Pick the right image format
Adjust compression
OpacityMask merge with brush, remove rgb
<Path Data="M 15.6,91.56 L 199.8,91.56 L 199.8,186 L 15.6,186 Z"
Clip="M 0,0 L 720,0 L 720,540 L 0,540 Z ">
<Path.OpacityMask>
<ImageBrush ImageSource=“image_3.png"
Viewbox="0,0,512,262" TileMode="None" ViewboxUnits="Absolute"
ViewportUnits="Absolute" Viewport="0,0,1,1">
<ImageBrush.Transform>
<MatrixTransform Matrix="184.2,0,0,94.44,15.6,91.56"/>
</ImageBrush.Transform>
</ImageBrush>
</Path.OpacityMask>
<Path.Fill>
<ImageBrush ImageSource=“image_4.png"
Viewbox="0,0,512,262" TileMode="None" ViewboxUnits="Absolute"
ViewportUnits="Absolute" Viewport="0,0,1,1">
<ImageBrush.Transform>
<MatrixTransform Matrix="184.2,0,0,94.44,15.6,91.56"/>
</ImageBrush.Transform>
</ImageBrush>
</Path.Fill>
</Path>
Name
Quality
Format
Size
image_3.png
1,1
32 bgra
47,934
Image_4.png
1,1
32 bgra
47,877
Merge.png
1,1
32 bgra
36,805
Merge.wmp
1,1
32 bgra
62,908
Merge.wmp
0.8,1
32 bgra
35,535
Merge.wmp
0.8,0.8
32 bgra
2,774
Merge.tiff
1,1
32 bgra
53,262
Merge.png
1,1
8 indexed
19,388
<Path Data="m0,0h1v1h-1z"
RenderTransform="184.2,0,0,94.44,15.6,91.56">
<Path.Fill> <ImageBrush ImageSource="merge256.png"
Viewbox="0,0,512,262" ViewboxUnits="Absolute“
ViewportUnits="Absolute" Viewport="0,0,1,1" />
</Path.Fill> </Path>
Read OPC/XPS specifications
Measure current XPS documents
Experiment with alternatives
Design/implement better XPS generation
Design/implement XPS optimization
XPS Related Web Resources
Specification, white papers, download:
http://www.microsoft.com/xps
Blog: http://blogs.msdn.com/xps
Forum:
http://forums.microsoft.com/msdn/showforum.aspx?forumid=126
Related Sessions
CLN-T370 XPSDrv: Best Practices using Print Verifier
CLN-C369 Print Verifier and XPSDrv Development Best Practices
CLN-C372 XPS Document Optimization and Best Practices
Technical
xpsinfo @ Support
microsoft.com
prninfo @ microsoft.com
© 2007 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.