Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic PrintPreview on Landscape (Read 5340 times)
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
PrintPreview on Landscape
Dec 18th, 2009 at 10:59pm
Print Post  
Is it possible to change the orientation to landscape just before print preview is called?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PrintPreview on Landscape
Reply #1 - Dec 21st, 2009 at 9:37am
Print Post  
Hi,

You will have to create a custom print-preview window as below, with paginator.PageSize set to the landscape size you need:

Code
Select All
private void OnFileCustomPrintPreview(object sender, RoutedEventArgs e)
{
	MemoryStream ms = new MemoryStream();
	Package pkg = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
	string pack = "pack://temp.xps";
	var uri = new Uri(pack);
	PackageStore.AddPackage(uri, pkg);
	XpsDocument doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
	XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);

	DocumentPaginator paginator = diagram.DocumentPaginator;
	paginator.PageSize = new Size(96 * 11, 96 * 8.5);
	rsm.SaveAsXaml(paginator);

	var w = new Window();
	DocumentViewer dv = new DocumentViewer();
	dv.Document = doc.GetFixedDocumentSequence();
	w.Content = dv;
	w.Title = "preview";
	w.Show();
	//PackageStore.RemovePackage(uri);
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: PrintPreview on Landscape
Reply #2 - Dec 22nd, 2009 at 11:15pm
Print Post  
Thanks. That worked for me.
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: PrintPreview on Landscape
Reply #3 - Dec 22nd, 2009 at 11:35pm
Print Post  
Actually. It only worked on print preview but when I printed it, it still printed on Portrait. Is it possible to change this behavior?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: PrintPreview on Landscape
Reply #4 - Dec 23rd, 2009 at 3:57pm
Print Post  
Try using the following class instead of DocumentViewer above:

Code
Select All
class MyDocumentViewer : DocumentViewer
{
	public MyDocumentViewer(Diagram diagram, PageOrientation defaultPrintOrientation)
	{
		this.diagram = diagram;
		this.defaultPrintOrientation = defaultPrintOrientation;
	}

	protected override void OnPrintCommand()
	{
		PrintTicket pt = new PrintTicket();
		pt.PageOrientation = defaultPrintOrientation;

		PrintDocumentImageableArea ia = null;
		XpsDocumentWriter w = PrintQueue.CreateXpsDocumentWriter(ref ia);
		if (w != null)
		{
			DiagramPaginator dp = (DiagramPaginator)diagram.DocumentPaginator;
			dp.PageSize = new Size(ia.MediaSizeHeight, ia.MediaSizeWidth);
			w.Write(dp, pt);
		}
	}

	Diagram diagram;
	PageOrientation defaultPrintOrientation;
}

MyDocumentViewer dv = new MyDocumentViewer(diagram, PageOrientation.Landscape); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: PrintPreview on Landscape
Reply #5 - Dec 23rd, 2009 at 6:02pm
Print Post  
Thanks a lot.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint