Answered by:
Rotate Contents Of XPS File in Print Preview Window

Question
-
Hello.
I have a user control MyUserControl (that contains several other user controls) that I write to an XPS file so that I can print preview MyUserControl.
The following code rotates MyUserControl from laying vertically to laying horizontally as required.
However the problem is that the whole print preview window with it's print and other icons are also rotated.
I tried rotating MyUserControl before writing it to an XPS file but that didn't work - it stayed vertical.
How can I get just MyUserControl within the print preview window to rotate and not have the whole print preview window rotate?
' Show the drawing surface in a new window Dim viewer As New DocumentViewer() Dim doc As New XpsDocument(tempFilePathFileName, FileAccess.Read) viewer.Document = doc.GetFixedDocumentSequence() doc.Close() ' Transform and arrange the design Dim pageAngle As Double = _design.Angle viewer.LayoutTransform = New RotateTransform(pageAngle) If pageAngle > 0 Then viewer.Arrange(New Rect(PageMarginLeft, PageMarginTop, LabelCompositionHeight, LabelCompositionWidth)) Else viewer.Arrange(New Rect(PageMarginLeft, PageMarginTop, LabelCompositionWidth, LabelCompositionHeight)) End If Dim type As Type = Me.GetType() Dim [assembly] As System.Reflection.Assembly = type.Assembly Dim win As Window = New Window win.Content = viewer win.Title = "Print Preview" win.WindowState = WindowState.Maximized win.ShowDialog()
Thanks,
RitaThursday, April 16, 2009 9:09 PM
Answers
-
When you emit the user control to XPS you may have to
a) Set the rotate transform on the parent of the user control
b) Swap the width and height of the parent of the user control
--Ifeanyi Echeruo [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.Friday, April 17, 2009 2:18 AM
All replies
-
When you emit the user control to XPS you may have to
a) Set the rotate transform on the parent of the user control
b) Swap the width and height of the parent of the user control
--Ifeanyi Echeruo [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.Friday, April 17, 2009 2:18 AM -
Thank you Ifeanyi.
Sorry for the delay - I had some time off from work.
I was actually doing what you suggested in a routine but then in my Print Preview routine I overwrote the code to rotate.
Once I removed the code from the Print Preview routine it worked as expected.Monday, April 27, 2009 8:32 PM