Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Print Preview (Read 8479 times)
Naomi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Print Preview
Aug 4th, 2009 at 10:26am
Print Post  
Hi,
Some questions about PrintPreview:
1. Can I set the page to be horizontal?
2. Can the preview be no modal dialog?
(meanning without locking the wpf base window)
3. The flow direction is defined right to left, but the print preview is shown as mirror?

Thanx.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview
Reply #1 - Aug 4th, 2009 at 2:55pm
Print Post  
Hi,

Diagram.PrintPreview() is implemented as follows:

Code
Select All
public void PrintPreview(string windowTitle)
{
	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);
	rsm.SaveAsXaml(DocumentPaginator);
	var w = new Window();
	DocumentViewer dv = new DocumentViewer();
	dv.Document = doc.GetFixedDocumentSequence();
	w.Content = dv;
	w.Title = windowTitle;
	w.ShowDialog();
	PackageStore.RemovePackage(uri);
}
 



1. Try setting diagram.Paginator.PageSize to a landscape rectangle before calling rsm.SaveAsXaml.

2. Call the Window.Show() method instead of ShowDialog().

3. What do you mean shown as mirror, does the page appear flipped horizontally?
  
Back to top
 
IP Logged
 
Naomi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Re: Print Preview
Reply #2 - Aug 4th, 2009 at 3:37pm
Print Post  
1. It does nothing.
2. If I change it to Show(), I see only the first page, and when i roll the mouse for the next page, I get error :
An exception of type 'System.UriFormatException' occurred and was caught.
Message : Invalid URI: The format of the URI could not be determined.
3. Yes, everything is opposite, as a mirror.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview
Reply #3 - Aug 6th, 2009 at 9:54am
Print Post  
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);
}
 



1. Yes, it does.
2. You should not call PackageStore.RemovePackage(uri) if the window must remain open.
3. Try setting dv.FlowDirection to LeftToRight, so it doesn't flip the Xaml it gets from the paginator, which I suppose is already in right-to-left direction.

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


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Re: Print Preview
Reply #4 - Aug 6th, 2009 at 12:34pm
Print Post  
Thank you.
3. It doesn't resolve this problem.
It affects the direction of the scroll bar, but the picture is still as a mirror.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview
Reply #5 - Aug 7th, 2009 at 1:49pm
Print Post  
The only way we've found to flip it is by applying a transfom to the returned page visual:

Code
Select All
public class RightToLeftPaginator : DocumentPaginator
{
	public RightToLeftPaginator(DocumentPaginator paginator)
	{
		this.paginator = paginator;
	}

	private DocumentPaginator paginator;

	public override DocumentPage GetPage(int pageNumber)
	{
		DocumentPage dp = paginator.GetPage(pageNumber);
		DrawingVisual dv = dp.Visual as DrawingVisual;
		dv.Transform = new ScaleTransform(-1, 1)
		{
			CenterX = paginator.PageSize.Width / 2,
			CenterY = paginator.PageSize.Height / 2
		};

		return dp;
	}

	public override bool IsPageCountValid
	{
		get { return paginator.IsPageCountValid; }
	}

	public override int PageCount
	{
		get { return paginator.PageCount; }
	}

	public override Size PageSize
	{
		get
		{
			return paginator.PageSize;
		}
		set
		{
			paginator.PageSize = value;
		}
	}

	public override IDocumentPaginatorSource Source
	{
		get { return paginator.Source; }
	}
}
 



Then in the preview code replace the paginator declaration with this one:

RightToLeftPaginator paginator = new RightToLeftPaginator(diagram.DocumentPaginator);

Stoyan
  
Back to top
 
IP Logged
 
Naomi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Re: Print Preview
Reply #6 - Aug 9th, 2009 at 6:41am
Print Post  
Thanx, it looks better.
But now, the header - the count of the pages, looks like a mirror...
Can I fix it? (or at least remove it?)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview
Reply #7 - Aug 10th, 2009 at 6:13am
Print Post  
You can remove it by setting diagram.PrintOptions.HeaderFormat to an empty string.
  
Back to top
 
IP Logged
 
Naomi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Re: Print Preview
Reply #8 - Aug 10th, 2009 at 7:48am
Print Post  
Thank you very much.
Another question I have:
The search text box doesn't work.
I searched for a word which I saw, but I got "can't find".
How do i get it to work?
  
Back to top
 
IP Logged
 
Naomi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 14th, 2009
Re: Print Preview
Reply #9 - Oct 22nd, 2009 at 2:19pm
Print Post  
Hi,
How can I set the default to landscape page?
The preview looks well, but when I print it, I have to change the preference to landscape manually.
How can I do it via the source code?

Thanx.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview
Reply #10 - Oct 22nd, 2009 at 3:47pm
Print Post  
Hi,

I suppose you will have to override the DocumentViewer.OnPrintCommand method, and print in landscape as shown here:
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=123129666...

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint