Hi

I have a problem with printing, this example should print 3 pages. 

If selecting preview it works, but printing (to either printer or file)
only gives me the first page. 

If setting 1-3 in Range it works.

And OnPaginate is never called.

Anyone have this problem ? or what am I doing wrong ?

/Mikkel

-----

Compile with:

gmcs -out:Test.exe -pkg:gtk-sharp-2.0 -r:Mono.Cairo Test.cs
mono Test.exe

------

Fedora 7

Mono JIT compiler version 1.2.3, (C) 2002-2006 Novell, Inc and
Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       normal
        Architecture:  x86
        Disabled:      none


gtk-sharp2-doc-2.10.0-4.fc7
njb-sharp-0.3.0-8.fc7
gtk-sharp2-2.10.0-4.fc7
gtk-sharp2-devel-2.10.0-4.fc7
gtk-sharp2-gapi-2.10.0-4.fc7
gnome-sharp-2.16.0-3.fc7
gnome-sharp-devel-2.16.0-3.fc7

namespace XCare.Test
{
	using System;
	using Gtk;
	using Cairo;
	
	public class TestPrint : Gtk.PrintOperation
	{
		public Pango.FontDescription desc;
		public int no = 1;
	
		public TestPrint ()
		{
		}
		
		public void Run ()
		{
			desc = Pango.FontDescription.FromString ("sans 12");
			
			PrintSettings settings = new PrintSettings ();
			this.PrintSettings = settings;
		
			this.Run (PrintOperationAction.PrintDialog, null);
		}
		
		protected override void OnRequestPageSetup (Gtk.PrintContext context, int page_nr, Gtk.PageSetup setup)
		{
			Console.WriteLine ("Request: " + no.ToString());
		}
		
		protected override bool OnPaginate (Gtk.PrintContext context)
		{
			Console.WriteLine ("Paginate: " + no.ToString());
			return true;
		}
		
		protected override void OnBeginPrint (Gtk.PrintContext context)
		{
			Console.WriteLine ("Begin: " + no.ToString());
			this.NPages = 1;
		}

		protected override void OnDrawPage (Gtk.PrintContext context, int pageNo)
		{
			Cairo.Context cr = context.CairoContext;	
			
			Pango.Layout layout = context.CreatePangoLayout ();
			layout.FontDescription = desc;

			string str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

			if (pageNo < 3) 
			{
				layout.Width = (int)(((20.0 * 72.0) / 2.54) * Pango.Scale.PangoScale);
				layout.Alignment = Pango.Alignment.Left;
				layout.SetMarkup (str);

				cr.MoveTo (0.0, 0.0);
				Pango.CairoHelper.ShowLayout (cr, layout);
			}	
			
			if (pageNo < 2)
			{
				this.NPages = ++no;
			}

			layout = null;
		}

		protected override void OnEndPrint (Gtk.PrintContext context)
		{
		}
		
		// Main
		public static void Main (string[] args)
		{
			Gtk.Application.Init ();
			
			new TestPrint ().Run ();
			
			Gtk.Application.Run ();
			
			Gtk.Application.Quit ();
		}
	}
}
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to