Click here to Skip to main content
15,880,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a Crsytal Report with the size 4x2, which is printing bill in a shop.
Printer is TVS JuSTBILL printer [Thermal Printer].
Its working, but at the time of printing after printing the actual text, the printer through lots of paper out from the printer like 2 to 3 inches paper[Roll paper does not have any fixed height, width is 4 inches]. That paper go wasted.

It is the problem.

Can we stop the printer after printing the actual printing, so that any blank page will not go wasted.
How to stop printer to eject extra paper from printer.
I am using the following code.

C#
private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(GlobalClass.constr);
            con.Open();
            SqlDataAdapter da3 = new SqlDataAdapter("select * from SalesDetails where BillNo='" + textBox1.Text + "'", con);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "SalesDetails");
            rptSalesbill abc = new rptSalesbill();
            abc.SetDataSource(ds3.Tables[0]);
            System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();
            int i;
            int rawKind = 0;
            for (i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++)
            {
                if (printDoc.PrinterSettings.PaperSizes[i].PaperName == "4x2")
                {
                    rawKind = (int)GetField(printDoc.PrinterSettings.PaperSizes[i], "kind");
                }
            }
            abc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
            abc.PrintToPrinter(1, true, 0, 0);
            crystalReportViewer1.Refresh();
        }
        private object GetField(Object obj, String fieldName)
        {
            System.Reflection.FieldInfo fi = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            return fi.GetValue(obj);
        }


Please Help me, I,m not getting any perfect answer regarding this question.
Posted
Updated 30-Aug-12 22:18pm
v3

1 solution

check your printer's / page's property is there any option available,
Source Document if it is then set it to [Feed,cut]
I have used Epson printer & notepad doc.

you can refer below link,
http://www.bigresource.com/VB-Change-Notepad-settings-from-VB-6-0-BcReZa4RRZ.html#slugrMccW9[^]
 
Share this answer
 
Comments
[no name] 30-Aug-12 8:29am    
you have used Epson printer & notepad doc.
but my printer TVS printer, I need the code print through notepad
can you please help me.

My printer doesn't have source document
but Paper source is there its contains
Tractor Feed
Automatically Select
Manual Paper Feed

I have choose tractor feed.

Can refer me any other link because that is good but not point to point.
please help
Aarti Meswania 30-Aug-12 8:33am    
ok, and crystal report's page is having same size '4x2'?
[no name] 30-Aug-12 8:37am    
my crystal report page size is 4x2
Aarti Meswania 30-Aug-12 8:43am    
create one notepad doc and print it using your tvs printer
check different-different Paper source property Tractor Feed,...
all that
check paper is wasting or not?
at which printer configuration you get desire print of notepad doc,
on that configuration check crystal report also

because generally bills are printed using notepad if paper-size is not regular
I have faced it but we have used notepad everytime
you can check for crystal-report & if get success then share your experience
else you have option of notepad which is used generally for bill printing
[no name] 30-Aug-12 8:48am    
What is the methodology.
I need to export the crystal report to notepad
for that I need to write the export code. ok.
Then I need to print that notepad file.
There in notepad, I don't have to provide the paper height.
Am I correct? and anther help!
Can you give a link to print notepad file through C#.

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