Witam, pierwszy raz pisze program który powinien coś drukować i już mam problem. Niestety nie działa mi tak jak bym chciał zawijanie tekstu na stronie.
public class ParagraphDocument : PrintDocument
{
private string text;
public string Text
{
get { return text; }
set { text = value; }
}
public ParagraphDocument(String text)
{
this.Text = text;
}
}
private void bDrukuj_Click(object sender, EventArgs e)
{
String text = "wefrwefew rgew rgergerger wgerwg"+
"wefrwefew rgew rgergerger wgerwg" + "wefrwefew rgew rgergerger wgerwg"+
"wefrwefew rgew rgergerger wgerwg" + "wefrwefew rgew rgergerger wgerwg" + "wefrwefew rgew rgergerger wgerwg";
PrintDocument doc = new ParagraphDocument(text);
doc.PrintPage+=new PrintPageEventHandler(this.Doc_PrintPage);
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;
if (dlgSettings.ShowDialog() == DialogResult.OK)
{ doc.Print();
}
}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
ParagraphDocument doc = (ParagraphDocument)sender;
Font font = new Font("Times New Roman", 14);
Font fontData = new Font("Times New Roman", 12);
Font fontTytul = new Font("Arial", 16,FontStyle.Bold);
float x = e.MarginBounds.Left;
float y=e.MarginBounds.Top+150;
e.Graphics.DrawString("Wrocław, dn. 2009-09-12", fontData, Brushes.Black, 520,e.MarginBounds.Top, StringFormat.GenericDefault);
e.Graphics.DrawString("Opinia psychologiczna", fontTytul, Brushes.Black, 290, e.MarginBounds.Top + 100, StringFormat.GenericDefault);
e.Graphics.DrawString("podpis i pieczęć", fontData, Brushes.Black, 540, e.MarginBounds.Bottom, StringFormat.GenericDefault);
e.Graphics.DrawString(doc.Text, font, Brushes.Black, <font color="red">x,y</font>, StringFormat.GenericDefault);
}
jeżeli zamiast tego dam e.MarginBounds to zawija tekst ale drukuje go od góry strony a ja potrzebuje żeby go drukował i zawijał własnie od float y=e.MarginBounds.Top+150;
Dziękuję za każdą pomoc. Pozdrawiam!