Page

How can I set the page size and other PageSetup parameters when creating and printing an XpsDocument?

PrintTicket pt = printQueue.UserPrintTicket;

pt.PageMediaSize.PageMediaSizeName =PageMediaSizeName.ISOA5;

seemed like the obvious thing but it is readonly.

Thanks

Michael

[499 byte] By [Michael] at [2008-2-22]
# 1

penny finally dropped. :)

PrintTicket pt = queue.UserPrintTicket;

pt.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA5);

but the following return nulls:-

Double? printableWidth = pt.PageMediaSize.Width;

Double? printableHeight = pt.PageMediaSize.Height;

Shouldn't these return the size of ISOA5?

Bug ?

Michael

Michael at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,XML Paper Specification (XPS)...
# 2

Michael,

You are very close with your current sample. The PageMediaSize is actually a class so you have to assign the property to a new instance of the class. Here is an example:

PrintTicket pt = printQueue.UserPrintTicket;

pt.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA5);

Thanks.

Daniel Emerson (MSFT)

DanielEmerson at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,XML Paper Specification (XPS)...
# 3

Michael,

These properties are only set if you assign values in the PageMediaSize constructor. There is an overload of the form PageMediaSize(Name, Width, Height) that will enable you to query these values..

Thanks.

-Daniel Emerson (MSFT)

DanielEmerson at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,XML Paper Specification (XPS)...
# 4

Hi Daniel,

Yes the penny finaly dropped - see second post.

... but why does pt.PageMediaSize.Width return null (same for Height) if it has been initalized with IS0A5?

Thanks

Michael

Michael at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,XML Paper Specification (XPS)...
# 5

Daniel,

(our posts maybe just crossed)

I'm using the overloaded constructor but isn't ISOA5 a known size? I'd like to understand the reasoning as to why Width and Height are not set to a default for the passed PageMediaSizeName. It means every WPF program must store these defaults when it could very easily be done by the runtime.

Thanks

Michael

Michael at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,XML Paper Specification (XPS)...

Software Development for Windows Vista

Site Classified