호텔 용 소프트웨어 응용 프로그램을 설계하고 있습니다. 감열 식 프린터에서 인보이스를 인쇄하고 DataGridView
에서 특정 열을 인쇄하고 싶습니다. 나는 대부분의 작업을했지만 항목의 이름이 커지면 문자열이 인쇄 영역 밖으로 이동합니다.감열 프린터에서 특정 형식의 송장을 인쇄하는 방법
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphic = e.Graphics;
Font font = new Font("Times New Roman", 8, FontStyle.Regular);
Font font2 = new Font("Times New Roman", 10, FontStyle.Bold);
float fontHeight = font.GetHeight();
int startX = 10;
int startY = 10;
int offset = 40;
graphic.DrawString("Welcome to Jaipur Rajwada", new Font("Times New Roman", 10, FontStyle.Bold), new SolidBrush(Color.Black), startX, startY);
graphic.DrawString("Jaipur-Delhi Highway", new Font("Times New Roman", 9, FontStyle.Italic), new SolidBrush(Color.Black), startX + 15, startY + 18);
int z = 1;
foreach (DataGridViewRow dr in dataGridViewSell.Rows)
{
string discription = dr.Cells[0].FormattedValue.ToString().PadRight(10);
string price = string.Format("{0:c}", dr.Cells[2].FormattedValue.ToString());
string quantity = dr.Cells[3].FormattedValue.ToString();
string total = string.Format("{0:c}", dr.Cells[4].FormattedValue.ToString());
string productline = z + " - " + discription + " - " + quantity + " - " + price + " - " + total;
graphic.DrawString(productline, font, new SolidBrush(Color.Black), startX - 3, startY + offset);
offset = offset + (int)fontHeight + 5;
z++;
}
offset = offset + 15;
graphic.DrawString("Total to Pay".PadRight(20) + String.Format("{0:c}", textBoxTotal.Text), font2, new SolidBrush(Color.Black), startX, startY + offset);
}
private void buttonPrint_Click(object sender, EventArgs e)
{
try
{
printReceipt();
}
catch (Exception ex)
{
throw ex;
}
}
나는 당신의 시도 캐치 당신은'MeasureString'를 사용하여 문자열의 길이를 계산하고 인쇄 영역을 초과하는 경우 일부 텍스트 줄 바꿈을 할 수있는, 그럼 조금 중복 .. – User2012384
생각합니다. –
가능한 [특정 형식으로 데이터를 인쇄하는 방법]의 중복. 그래서 그것이 인쇄하는 동안 mydesign을 사라지지 않습니다] (http://stackoverflow.com/questions/27523688/how-to-print-data-in-a-particular-format-so-that-it-doesnt-vanish- mydesign-whi) – Junaith