[Mono-winforms-list] print/print preview not working for drawstring
marchino at yota.it
marchino at yota.it
Fri Aug 1 12:18:18 EDT 2008
Yes of course:
here is the code:
..............................
void Button1Click(object sender, EventArgs e)
{
stampa();
}
public void stampa()
{
PrintDocument Doc = new PrintDocument();
Doc.DocumentName = "Test di
stampa"+DateTime.Now.ToFileTime();//DateTime.Now.Ticks.ToString();
Doc.DefaultPageSettings.Landscape = false;
Doc.PrintPage += new PrintPageEventHandler(testToPrinter);
Margins margins = new Margins(0,0,0,0);
Doc.DefaultPageSettings.Margins = margins;
if (chkAnteprima.Checked)
{
PrintPreviewDialog Preview = new PrintPreviewDialog();
Preview.Document = Doc;
Preview.WindowState = FormWindowState.Maximized;
Preview.UseAntiAlias = true;
Preview.ShowDialog();
}
else
{
PrintDialog Print = new PrintDialog();
Print.Document = Doc;
Print.AllowSomePages = true;
Print.AllowSelection = false;
Print.AllowPrintToFile = false;
Print.AllowCurrentPage = false;
Print.ShowHelp = false;
if(Print.ShowDialog() == DialogResult.OK)
{
Doc.PrinterSettings = Print.PrinterSettings;
Doc.Print();
}
}
}
private void testToPrinter(Object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.PageUnit = GraphicsUnit.Millimeter;
Color mioTesto = Color.Red;
StringFormat drawNomeFormat = new StringFormat();
StringFormat drawCorsoFormat = new StringFormat();
drawNomeFormat.Alignment = StringAlignment.Center;
drawNomeFormat.LineAlignment = StringAlignment.Center;
Brush br = new SolidBrush(Color.Black);
Rectangle r1a = new Rectangle(35,85,135,50);
Font fontNome = new Font("Arial", 12);
g.DrawString("nome 1", fontNome, br, r1a,
drawNomeFormat);
e.HasMorePages = false;
}
..............................
many thanxs
mARCO
Andreia Gaita ha scritto:
> On 7/24/08, funkgui <marchino at yota.it> wrote:
>
>> in windows using mono all is ok (version 1.2.5) on linux (same mono version)
>> is all ok but I can't print/print preview strings?????
>>
>> Has anybody any idea?
>>
>> I can print images and lines and polygons but not strings(method drawstring)
>>
>
> Could you post a small code sample to reproduce this problem, please?
>
> andreia gaita
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20080801/e9a73d3c/attachment.html
More information about the Mono-winforms-list
mailing list