2015-09-21 93 views
-1

如何更改我的打印字體大小?這是我正在使用的代碼。如何更改打印中的字體大小?

private void PrintDocumentOnPrintPage(object sender, PrintPageEventArgs e) 
{ 
    e.Graphics.DrawString(
     this.textBox5.Text + " " + this.textBox6.Text + " - " + this.textBox8.Text, 
     this.textBox5.Font, Brushes.Black, 10, 25);    
} 

private void button1_Click(object sender, EventArgs e) 
{ 
    MessageBox.Show("Bienvenido, Toma tú Gafete!");  
    PrintDocument printDocument = new PrintDocument(); 
    printDocument.PrintPage += PrintDocumentOnPrintPage; 
    printDocument.Print(); 
}  

回答

0

您可以使a new Font object具有與舊字體相同的家族和風格,但大小不同;然後將該字體傳遞給DrawString而不是舊字體。

float size = 14; // for example 
var oldFont = textBox5.Font; 
var newFont = new Font(oldFont.FontFamily, size, oldFont.FontStyle); 

e.Graphics.DrawString(
    this.textBox5.Text + " " + this.textBox6.Text + " - " + this.textBox8.Text, 
    newFont, Brushes.Black, 10, 25);    
+0

完美!有用!謝謝! –