I have a receipt printing application
Receipt height is just 4 Inch (Pre printed Roll paper, Epson dotmatrix printer)
Printer head is at 1 & 1/2 INCH is below from top of the paper (with cutting marks)
I want to start print just 1/2 INCH below from top of the paper, so before start printing
paper must be pulled 1 INCH down,
thanks in advance
Amit GuptaPosted Dec 29, 2018, 5:17 AM
irfan sheriefPosted Dec 29, 2018, 4:53 AM
{
Font fnt10 = new Font("Verdana", 10, GraphicsUnit.Point);//Microsoft Sans Serif
//Font fnt10m = new Font("ML-TTKarthika", 10, GraphicsUnit.Point);// kartika
Font fnt10m = new Font("Verdana", 10, GraphicsUnit.Point);// kartika
int x = 0, y = 0; DataGridViewRow row;
try
{
y = int.Parse(txtNoTop.Text); x = int.Parse(txtNoLeft.Text);
e.Graphics.DrawString(txtEntryNo.Text, fnt10, Brushes.Black, x, y); x = int.Parse(txtDateLeft.Text);
e.Graphics.DrawString(dtpDate.Text, fnt10, Brushes.Black, x, y);
y = int.Parse(txtNameTop.Text); x = int.Parse(txtNameLeft.Text);
TextRenderer.DrawText(e.Graphics, txtDevotee.Text, fnt10m, new Point(x, y), Color.Black);
x = int.Parse(txtMobLeft.Text);
TextRenderer.DrawText(e.Graphics, txtMobileNo.Text, fnt10m, new Point(x, y), Color.Black);
y = int.Parse(txtVilasomTop.Text); x = int.Parse(txtVilasomLeft.Text);
temp = txtAddress2.Text.Equals("") ? "" : "," + txtAddress2.Text;
TextRenderer.DrawText(e.Graphics, txtAddress2.Text + temp, fnt10m, new Point(x, y), Color.Black);
y = int.Parse(txtColTop.Text);
for (i = 0; i < g1.RowCount - 1; i++)
{
row = g1.Rows[i];
if (!row.Cells[vpn].Value.ToString().Equals("") && row.Cells[nm].Value.ToString().Trim().Length > 2 && !row.Cells[nkn].Value.ToString().Equals(""))
{
if (chkPrintSlNoVpReceipt.Checked)
{
x = int.Parse(txtColLeft.Text); sl++;
TextRenderer.DrawText(e.Graphics, (sl).ToString(), fnt10m, new Point(x, y), Color.Black);
}
x = int.Parse(txtCol2Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[nm].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
x = int.Parse(txtCol3Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[nk].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
if (!prevVazhipad.Equals(row.Cells[vp].Value.ToString()) || repeatVazhipad.Equals("1"))
{
x = int.Parse(txtCol4Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[vp].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
}
x = int.Parse(txtCol5Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[fe].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
y = y + 20; total = total + float.Parse(row.Cells[fe].Value.ToString());
}
prevVazhipad = row.Cells[vp].Value.ToString();
}
y = int.Parse(txtTotalTop.Text); x = int.Parse(txtTotalLeft.Text);
e.Graphics.DrawString(string.Format(fmtStr, total), bfnt16, Brushes.Black, x, y);
}
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
}
Amit GuptaPosted Dec 29, 2018, 2:50 AM
irfan sheriefPosted Dec 29, 2018, 2:07 AM
{
Font bfnt22 = new Font("Verdana", 22, FontStyle.Bold, GraphicsUnit.Point);
Font fnt18 = new Font("Verdana", 18, GraphicsUnit.Point);
Font bfnt18 = new Font("Verdana", 18, FontStyle.Bold, GraphicsUnit.Point);
Font bfnt16 = new Font("Verdana", 16, FontStyle.Bold, GraphicsUnit.Point);
Font ufnt18 = new Font("Verdana", 18, FontStyle.Underline, GraphicsUnit.Point);
Font fnt14 = new Font("Verdana", 14, GraphicsUnit.Point);
Font ufnt14 = new Font("Verdana", 14, FontStyle.Underline, GraphicsUnit.Point);
Font fnt10 = new Font("Verdana", 10, GraphicsUnit.Point);//Microsoft Sans Serif
//Font fnt10m = new Font("ML-TTKarthika", 10, GraphicsUnit.Point);// kartika
Font fnt10m = new Font("Verdana", 10, GraphicsUnit.Point);// kartika
Font ifnt10 = new Font("Verdana", 10, FontStyle.Italic, GraphicsUnit.Point);
Font bfnt10 = new Font("Verdana", 10, FontStyle.Bold, GraphicsUnit.Point);
Font bfnt12 = new Font("Verdana", 12, FontStyle.Bold, GraphicsUnit.Point);
Font fnt12 = new Font("Verdana", 12, GraphicsUnit.Point);//twelve font
Font bfnt14 = new Font("Verdana", 14, FontStyle.Bold, GraphicsUnit.Point);
SizeF sz; int yEndPoint = 0, x = 20, y = 20, i = 0, x1 = 0, x2 = 765, noOfItems = 0,yBeginPoint=0;
DataGridViewRow row;
string bf = new String((char)14, 1), nf = new String((char)15, 1), companyName = "";
string dealerName = "", secondLine = "", thirdLine = "", greeting = "NA", greetingTop = "NA";
string currUser = "", prnText = "", temp = ""; float fee = 0, total = 0;
int pullPaperDown = 0, pushPaperUp = 0, printHeader = 0, linesBetweenHeaderBody = 0, leftMargin = 0;
int captionId = 1, fixedLines = 0, prnOffset = 0, sl = 0, greetingsSize = 0;
string showAsOnBalance = "0", billHeader = "??????? ?????", prevVazhipad = "", repeatVazhipad="";
//bool printedForm = btnPrintWin.Tag.ToString().Equals("1") ? true : false;
try
{
pullPaperDown = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='pullPaperDown'"));
pushPaperUp = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='pushPaperUp'"));
printHeader = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='printHeader'"));
fixedLines = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='fixedLines'"));
linesBetweenHeaderBody = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='linesBetweenHeaderBody'"));
leftMargin = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='leftMargin'"));
prnOffset = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='prnOffset'"));
greetingsSize = int.Parse(DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='greetingsSize'"));
repeatVazhipad = DbModule.getSingleFieldT("registryTable", "entryValue", "fentry='repeatVazhipad'");
Font gfnt = new Font("Verdana", greetingsSize, FontStyle.Bold, GraphicsUnit.Point);
if (chkPrePrintedForm.Checked == false)
{
if (printHeader == 1)
{
greetingTop = DbModule.getSingleFieldT("captionsSub", "entryValue", "fentry='zeroLine' AND captionId=" + captionId);
companyName = DbModule.getSingleFieldT("captionsSub", "nentryValue", "fentry='companyName' AND captionId=" + captionId);
secondLine = DbModule.getSingleFieldT("captionsSub", "nentryValue", "fentry='secondLine' AND captionId=" + captionId);
thirdLine = DbModule.getSingleFieldT("captionsSub", "entryValue", "fentry='thirdLine' AND captionId=" + captionId);
}
greeting = DbModule.getSingleFieldT("miselanias", "entryValue", "entries='greetings'");
currUser = DbModule.getSingleFieldT("users", "usar", "userId=" + DbModule.loginUserId);
x1 = prnOffset; x2 = 700; x = x1; y = y + 30;
if (printHeader == 1)
{
if (greetingTop != "NA")
{
sz = e.Graphics.MeasureString(greetingTop, ifnt10);
e.Graphics.DrawString(greetingTop, ifnt10, Brushes.Black, x1 + ((x2 - x1) - sz.Width) / 2, y);
y = y + 17;
}
sz = e.Graphics.MeasureString(companyName, bfnt18);
e.Graphics.DrawString(companyName, bfnt18, Brushes.Black, x1 + ((x2 - x1) - sz.Width) / 2, y);
y = y + 30; sz = e.Graphics.MeasureString(secondLine, bfnt10);
e.Graphics.DrawString(secondLine, bfnt10, Brushes.Black, x1 + ((x2 - x1) - sz.Width) / 2, y);
y = y + 25;
}
prnText = billHeader; sz = e.Graphics.MeasureString(prnText, ufnt14);
e.Graphics.DrawString(prnText, ufnt14, Brushes.Black, x1 + ((x2 - x1) - sz.Width) / 2, y);
for (i = 1; i <= linesBetweenHeaderBody; i++) { y = y + 10; }
y = y + 30; x = x1;
e.Graphics.DrawString("????? ??: " + txtEntryNo.Text, fnt10, Brushes.Black, x, y); x = 480;
e.Graphics.DrawString("?????: " + dtpDate.Text, fnt10, Brushes.Black, x, y);
y = y + 25; x = x1;
e.Graphics.DrawString("?????? ????: " + txtDevotee.Text, fnt10, Brushes.Black, x, y); x = 480;
e.Graphics.DrawString("?????? ??: " + txtMobileNo.Text, fnt10, Brushes.Black, x, y);
y = y + 20; x = x1; temp = txtAddress2.Text.Equals("") ? "" : "," + txtAddress2.Text;
e.Graphics.DrawString("??????: " + txtAddress2.Text + temp, fnt10, Brushes.Black, x, y);
y = y + 25; x = x1; yBeginPoint = y - 5;
x = x1; e.Graphics.DrawLine(Pens.Red, new Point(x, y - 5), new Point(x2, y - 5)); //HR
x = x1; temp = "??"; x = x + CModule.accw(temp, 40, fnt10, e.Graphics);
e.Graphics.DrawString(temp, fnt10, Brushes.Black, x, y);
x = 100; e.Graphics.DrawString("????? ???????", fnt10, Brushes.Black, x + 10, y);
x = 300; e.Graphics.DrawString("????????", fnt10, Brushes.Black, x + 10, y);
x = 420; e.Graphics.DrawString("???????", fnt10, Brushes.Black, x + 10, y);
x = 620; temp = "???"; x = x + CModule.accw(temp, x2 - x, fnt10, e.Graphics);
e.Graphics.DrawString(temp, fnt10, Brushes.Black, x, y); y = y + 20;
e.Graphics.DrawLine(Pens.Red, new Point(x1, y), new Point(x2, y)); y = y + 10; //HR
for (i = 0; i < g1.RowCount - 1; i++)
{
row = g1.Rows[i];
if (!row.Cells[vpn].Value.ToString().Equals("") && row.Cells[nm].Value.ToString().Trim().Length > 2 && !row.Cells[nkn].Value.ToString().Equals(""))
{
x = x1; sl++; temp = (sl).ToString(); x = x + CModule.accw(temp, 60, fnt10, e.Graphics);
e.Graphics.DrawString(temp, fnt10, Brushes.Black, x, y);
x = 100; e.Graphics.DrawString(row.Cells[nm].Value.ToString(), fnt10, Brushes.Black, x + 10, y);
x = 300; e.Graphics.DrawString(row.Cells[nk].Value.ToString(), fnt10, Brushes.Black, x + 10, y);
x = 420; e.Graphics.DrawString(row.Cells[vp].Value.ToString(), fnt10, Brushes.Black, x + 10, y);
x = 620; temp = row.Cells[fe].Value.ToString(); x = x + CModule.rjjw(temp, x2 - x, fnt10, e.Graphics);
e.Graphics.DrawString(temp, fnt10, Brushes.Black, x, y); y = y + 20; total = total + float.Parse(temp);
}
}
for (i = noOfItems; i < fixedLines; i++) { y = y + 15; }
yEndPoint = y;
x = x1; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
x = 100; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
x = 300; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
x = 420; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
x = 620; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
x = x2; e.Graphics.DrawLine(Pens.Red, new Point(x, yBeginPoint), new Point(x, yEndPoint));
e.Graphics.DrawLine(Pens.Red, new Point(x1, y), new Point(x2, y));//HR
//y = y+ 35; e.Graphics.DrawLine(Pens.Red, new Point(x1, y), new Point(x2, y));//HR
y = y + 15; x = 120; temp = "??? ???: ??? " + string.Format(fmtStr, total) + "/- ??????";
e.Graphics.DrawString(temp, bfnt16, Brushes.Black, x, y);
y = y + 50; prnText = "????? ????????? ???????????? ???????"; x = 390;
e.Graphics.DrawString(prnText, fnt10, Brushes.Black, x, y); y = y + 20;
e.Graphics.DrawLine(Pens.Red, new Point(x1, y), new Point(x2, y));
y = y + 5; x = x1; e.Graphics.DrawString("???????? ????? ???????: " + currUser, fnt10, Brushes.Black, x, y);
if (greeting != "NA")
{
y = y + 25; sz = e.Graphics.MeasureString(greeting, gfnt);
e.Graphics.DrawString(greeting, gfnt, Brushes.Black, x1 + ((x2 - x1) - sz.Width) / 2, y);
}
}
else
{
y = int.Parse(txtNoTop.Text); x = int.Parse(txtNoLeft.Text);
e.Graphics.DrawString(txtEntryNo.Text, fnt10, Brushes.Black, x, y); x = int.Parse(txtDateLeft.Text);
e.Graphics.DrawString(dtpDate.Text, fnt10, Brushes.Black, x, y);
y = int.Parse(txtNameTop.Text); x = int.Parse(txtNameLeft.Text);
TextRenderer.DrawText(e.Graphics, txtDevotee.Text, fnt10m, new Point(x, y), Color.Black);
x = int.Parse(txtMobLeft.Text);
//e.Graphics.DrawString(txtMobileNo.Text, fnt10, Brushes.Black, x, y);
TextRenderer.DrawText(e.Graphics, txtMobileNo.Text, fnt10m, new Point(x, y), Color.Black);
y = int.Parse(txtVilasomTop.Text); x = int.Parse(txtVilasomLeft.Text);
temp = txtAddress2.Text.Equals("") ? "" : "," + txtAddress2.Text;
TextRenderer.DrawText(e.Graphics, txtAddress2.Text + temp, fnt10m, new Point(x, y), Color.Black);
//e.Graphics.DrawString(txtAddress2.Text + temp, fnt10, Brushes.Black, x, y);
y = int.Parse(txtColTop.Text);
for (i = 0; i < g1.RowCount - 1; i++)
{
row = g1.Rows[i];
if (!row.Cells[vpn].Value.ToString().Equals("") && row.Cells[nm].Value.ToString().Trim().Length > 2 && !row.Cells[nkn].Value.ToString().Equals(""))
{
if (chkPrintSlNoVpReceipt.Checked)
{
x = int.Parse(txtColLeft.Text); sl++;
//e.Graphics.DrawString((sl).ToString(), fnt10, Brushes.Black, x, y);
TextRenderer.DrawText(e.Graphics, (sl).ToString(), fnt10m, new Point(x, y), Color.Black);
}
x = int.Parse(txtCol2Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[nm].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
//e.Graphics.DrawString(row.Cells[nm].Value.ToString(), fnt10m, Brushes.Black, x + 10, y);
x = int.Parse(txtCol3Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[nk].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
//e.Graphics.DrawString(row.Cells[nk].Value.ToString(), fnt10, Brushes.Black, x + 10, y);
if (!prevVazhipad.Equals(row.Cells[vp].Value.ToString()) || repeatVazhipad.Equals("1"))
{
x = int.Parse(txtCol4Left.Text);
TextRenderer.DrawText(e.Graphics, row.Cells[vp].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
//e.Graphics.DrawString(row.Cells[vp].Value.ToString(), fnt10, Brushes.Black, x + 10, y);
}
x = int.Parse(txtCol5Left.Text);
//e.Graphics.DrawString(row.Cells[fe].Value.ToString(), fnt10, Brushes.Black, x, y);
TextRenderer.DrawText(e.Graphics, row.Cells[fe].Value.ToString(), fnt10m, new Point(x, y), Color.Black);
y = y + 20; total = total + float.Parse(row.Cells[fe].Value.ToString());
}
prevVazhipad = row.Cells[vp].Value.ToString();
}
y = int.Parse(txtTotalTop.Text); x = int.Parse(txtTotalLeft.Text);
e.Graphics.DrawString(string.Format(fmtStr, total), bfnt16, Brushes.Black, x, y);
}
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
finally { senderObj = ""; }
}
Amit GuptaPosted Dec 29, 2018, 12:13 AM
irfan sheriefPosted Dec 28, 2018, 9:10 PM
Amit GuptaPosted Dec 25, 2018, 12:00 AM