Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing billing software.
After bill print whole roll paper is ejected (dot matrix).

Guide me to stop eject paper through c#.
Posted
Updated 6-Nov-11 2:16am
v2
Comments
RaisKazi 5-Nov-11 7:18am    
Don't you think Title and Descrption of your Question are little contrary? Make sure you want to do this using VB/C#.
Mehdi Gholam 6-Nov-11 2:05am    
How are you printing, doing it yourself, with a component?
Dalek Dave 6-Nov-11 8:17am    
Edited for Grammar and Readability

In VB or C#?(Your Question Tag & title shows both)

I'm always sick of dot matrix printing issues X| Anyway I'll give you a bunch, check it!

VB 2008 print bill on roll paper[^](OP solved himself)
page ejecting on printer[^]
How to dynamic control paper (feed) without eject paper on SDR, printing on dot matrix printer with roll paper[^]
Stop ejecting remaining space after printing using VB 6.0[^]
How to avoid paper ejection[^]

Free attachment
And a nice article for you
A .NET Text Printing Class... That Works![^]

Please convert the VB code into C# yourself. BTW I think you are lucky(got many links regarding this)
 
Share this answer
 
Comments
Dalek Dave 6-Nov-11 8:17am    
Good answer
thatraja 6-Nov-11 8:23am    
Thank you, Its been long time I got 5 from you(I'm back to Q/A section today only after long time).
BTW noticed my name in CCC list, Thanks again.
http://support.microsoft.com/?kbid=322091
 
Share this answer
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
using System.Data.SqlClient;


namespace PrintApp
{
public partial class Form1 : Form
{
private PrintDocument printDocument1 = new PrintDocument();
private string stringToPrint;
int cntng;
public Form1()
{
InitializeComponent();
printDocument1.PrintPage+=new PrintPageEventHandler(printDocument1_PrintPage);

}

private void button1_Click(object sender, EventArgs e)
{
string query = Application.StartupPath + "\\text.txt";
using (StreamWriter sw = new StreamWriter(Application.StartupPath + "\\text.txt"))
{
sw.WriteLine("BILL WISE PROFIT REPORT");
}
ReadFile();
printDocument1.Print();



}
private void ReadFile()
{

using (StreamReader sr = new StreamReader(Application.StartupPath + "\\text.txt"))
{
cntng = File.ReadAllLines(Application.StartupPath + "\\text.txt").Length;
for (int i = 0; i < cntng; i++)
{

stringToPrint = sr.ReadToEnd();

}

}

}

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
Font printfont = new Font("TAMKural", 10);
e.Graphics.MeasureString(stringToPrint, printfont,
e.MarginBounds.Size, StringFormat.GenericTypographic,
out charactersOnPage, out linesPerPage);
e.Graphics.DrawString(stringToPrint, printfont, Brushes.Black,
e.MarginBounds, StringFormat.GenericTypographic);
stringToPrint = stringToPrint.Substring(charactersOnPage);

e.HasMorePages = (stringToPrint.Length > 0);



}
}
}
 
Share this answer
 
Comments
igetorix 7-Dec-11 8:34am    
Dear Sir,

Is Yours solution tested ? Can it do what the question "How to stop paper ejecting in vb while using printer object" ask ?
Can You attach a working sample ?

ty for answer ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900