[Mono-winforms-list] Creating printpreview using cairo + winforms
rav
gontar88 at gmail.com
Wed Aug 24 05:51:08 EDT 2011
Hi
I'm trying to print cairo image using winforms. When i create default print
preview dialog, the image created by cairo is very small. It's probably
caused by different resolutions of cairo and winforms. Is there any way to
fix it?? I tried to use fallbackresolution method of cairo win32surface,but
that doesnt work. Everything is ok when i print on dialog context but not on
printpreview:(
code:
private void CreatePagePreview(object sender, PrintPageEventArgs arg)
{
Win32Surface w32s = new Win32Surface(arg.Graphics.GetHdc());
Cairo.Context wcont= new Context(w32s);
//...printing on cairo surface...
w32s.Finish();
g.ReleaseHdc(w32s.Handle);
((IDisposable)wcont).Dispose();
g.Dispose();
}
I tried to create an image on ImageSurface and then copy it to win32surface
but that also doesnt work correctly
code:
private void CreatePagePreview(object sender, PrintPageEventArgs arg)
{
int Width = prtdoc.DefaultPageSettings.PaperSize.Width;
int Height = prtdoc.DefaultPageSettings.PaperSize.Height;
Cairo.ImageSurface img = new ImageSurface(Format.ARGB32,width, height);
Cairo.Context cr = new Context(img);
//...printing on cairo surface...
img.Finish();
Cairo.Win32Surface w32s = new Win32Surface(arg.Graphics.GetHdc());
Cairo.Context wcont= new Context(w32s);
wcont.SetSourceSurface(img, 0, 0);
w32s.Finish();
g.ReleaseHdc(w32s.Handle);
((IDisposable)wcont).Dispose();
((IDisposable)cr).Dispose();
g.Dispose();
}
Thanks for help and sorry for my english :)
--
View this message in context: http://mono.1490590.n4.nabble.com/Creating-printpreview-using-cairo-winforms-tp3764897p3764897.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.
More information about the Mono-winforms-list
mailing list