Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) DocumentPaginator Creates Blank Pages (Read 10318 times)
benm
YaBB Newbies
*
Offline


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
DocumentPaginator Creates Blank Pages
Apr 7th, 2010 at 9:02pm
Print Post  
I have created my own print preview and I have implemented an option to fit the digram to a single page. Here is what I have so far (unimportant code is omitted):

Code
Select All
double pageWidth = 8.5 * 96;
double pageHeight = 11 * 96;
ScrollViewerDiagram.Height = pageHeight - 96;  // -96 accounts for margins
ScrollViewerDiagram.Width = pageWidth - 96;
ScrollViewerDiagram.Content = diagram;
diagram.ZoomToFit();

//generate temporary file name
string uri = System.IO.Path.GetTempFileName();
if (File.Exists(uri) == true)
    File.Delete(uri);

XpsDocument doc = new XpsDocument(uri, FileAccess.ReadWrite);
XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);

DocumentPaginator paginator = diagram.DocumentPaginator;
paginator.PageSize = new Size(pageWidth, pageHeight);
rsm.SaveAsXaml(paginator); 



This creates a beautiful document with the diagram all on one page, but there are three for four blank pages in the document. Is there an easy fix for this without having to create a new document and copy over only the first page?  Am I approaching this the right way to fit the diagram to a single page?

-Ben
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #1 - Apr 8th, 2010 at 3:34pm
Print Post  
Hi Ben,

Try setting diagram.PrintOptions.Scale = diagram.ZoomFactor before getting the paginator.

Stoyan
  
Back to top
 
IP Logged
 
benm
YaBB Newbies
*
Offline


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
Re: DocumentPaginator Creates Blank Pages
Reply #2 - Apr 8th, 2010 at 4:54pm
Print Post  
Hi Stoyan,

That did not seems to affect the output.  If I comment the ZoomToFit() line, it does in fact need 4 pages.  When I leave in the ZoomToFit(), it is all on 1 page, but there are still 4 pages, 3 of which are blank.

For some reason I can set diagram.PrintOptions.Scale to anything and it does not affect the output.

-Ben
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #3 - Apr 8th, 2010 at 5:52pm
Print Post  
This won't affect the scale of the diagram on screen since you are not showing the visual returned by paginator.getPage, but it should still affect the number of pages. Could you try setting a bit smaller Scale than the one calculated by ZoomTiFit? Also try calling UpdateLayout on the scroll-viewer before ZoomToFit.

Stoyan
  
Back to top
 
IP Logged
 
benm
YaBB Newbies
*
Offline


I <3 MindFusion

Posts: 32
Location: CA
Joined: Dec 10th, 2008
Re: DocumentPaginator Creates Blank Pages
Reply #4 - Apr 9th, 2010 at 6:32am
Print Post  
This does not seem to help either.  No matter what the diagram.PrintOptions.Scale is set to, there is always the same number of pages.  I verified that diagram.IsLoaded returns true and also tried UpdateLayout.  For now, I will just extract the first page and create a new XPS document.  Let me know if you have any further insights though.  It must be some sort of layout / render / measure issue I would imagine.
  
Back to top
WWW  
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #5 - Jul 30th, 2010 at 1:38pm
Print Post  
I have the same issue.

When i change the scale and call the ComputePageCount method in the DocumentPaginator, the number of blank pages are still the same.
Even when i change the scale in a high number, i allway's get 20 pages to print. ???


uses: Mindfusion WpfDiagram version 2.2
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #6 - Jul 30th, 2010 at 2:05pm
Print Post  
Try the latest version 2.4; PrintOptions.Scale seems to work fine in my test with it.

Stoyan
  
Back to top
 
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #7 - Aug 2nd, 2010 at 8:48am
Print Post  
Correct, the latest greatest did the trick.

Thnx.
  
Back to top
 
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #8 - Aug 2nd, 2010 at 10:54am
Print Post  
How is PrintPreview implemented in 2.4?

Because our product is allready released with WpfDiagram 2.2.0.25609 and are unable (restricted) to upgrade.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #9 - Aug 2nd, 2010 at 11:44am
Print Post  
  
Back to top
 
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #10 - Aug 2nd, 2010 at 12:52pm
Print Post  
I used the DocumentPaginator as in the example.

What is exactly the 'fix' between version 2.4 and 2.2 that don't creates blank pages?

There sould be a solution available to work arround this problem.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #11 - Aug 2nd, 2010 at 1:37pm
Print Post  
From what I can see in the VSS history, the fix is that PageCount now considers PrintOptions.Scale and previously it did not. I suppose you can override DiagramPaginator.PageCount to scale the number of pages and then use the custom paginator instead of the built-in print method, which is implemented as below:

Code
Select All
public void Print()
{
	PrintDocumentImageableArea ia = null;
	XpsDocumentWriter w = PrintQueue.CreateXpsDocumentWriter(ref ia);

	if (w != null)
	{
		DiagramPaginator dp = (DiagramPaginator)DocumentPaginator;
		dp.PageSize = new Size(ia.MediaSizeWidth, ia.MediaSizeHeight);
		w.Write(dp);
	}
} 



If you have a version with source code, we could also send you the latest DiagramPaginator.cs so you can rebuild your version 2.2 with it.
  
Back to top
 
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #12 - Aug 3rd, 2010 at 7:31am
Print Post  
Yes that would be nice.

Because i don't know exactly how the number of page's is calculated.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DocumentPaginator Creates Blank Pages
Reply #13 - Aug 3rd, 2010 at 8:05am
Print Post  
Please email your license information to support@mindfusion.eu to get the updated paginator.cs code.
  
Back to top
 
IP Logged
 
Bastian
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 30th, 2010
Re: DocumentPaginator Creates Blank Pages
Reply #14 - Aug 9th, 2010 at 10:32am
Print Post  
I see that the page calculations is now fixed, but when my diagram can be print in 4 pages it needs 7 pages to display the hole diagram in the printpreview in that case it has 3 blank pages in between.

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint