Hi everybody.

I want to transform geometric figures from xaml to xps with the following code, but if i print this figure to paper the figures a little bit smaller than defined.

Code Block

void XamlFileToXps(string srcXamlFile, string destXpsFile)


using(Stream fileStream = File.OpenRead(srcXamlFile))


ParserContext context = new ParserContext();

context.BaseUri = new Uri(Directory.GetCurrentDirectory() + "//");

XamlStreamToXps(fileStream, context, destXpsFile);



void XamlStreamToXps(Stream srcXamlStream, ParserContext context, string destXpsFile)


XpsDocument document = new XpsDocument(destXpsFile, FileAccess.ReadWrite);

XpsPackagingPolicy packagePolicy = new XpsPackagingPolicy(document);

XpsSerializationManager serializationMgr = new XpsSerializationManager(packagePolicy, false);

object parsedDocObject = (null == context)

XamlReader.Load(srcXamlStream) :

XamlReader.Load(srcXamlStream, context);




The xaml code

Code Block






<Grid Height="482" Width="530">

<Rectangle Stroke="Green" StrokeThickness="1" Width="5cm" Height="10cm">




As you can I defined a Width="5cm" Height="10cm" (I try it also with in and px) but on the Paper i got a rectangle 4,58cm x 9,7cm

Anny suggestions

Thx Wolfgang

Re: XML Paper Specification (XPS) Is it possible to print a rectangle with exact width and high ?

adrian ford [MSFT]

Have you checked the size of the same element in the output XPS file I suspect it's correct and that the driver you're printing to the device through is scaling.