Click here to Skip to main content
13,198,563 members (27,609 online)
Rate this:
Please Sign up or sign in to vote.
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.

private void button1_Click(object sender, EventArgs e)
            SqlConnection con = new SqlConnection(GlobalClass.constr);
            SqlDataAdapter da3 = new SqlDataAdapter("select * from SalesDetails where BillNo='" + textBox1.Text + "'", con);
            DataSet ds3 = new DataSet();
            da3.Fill(ds3, "SalesDetails");
            rptSalesbill abc = new rptSalesbill();
            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);
        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 29-Aug-12 10:36am
Updated 30-Aug-12 22:18pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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,[^]
Sourav Sarkar-SS 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'?
Sourav Sarkar-SS 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
Sourav Sarkar-SS 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#.
aarti meswania 30-Aug-12 8:59am
you can not export to notepad file directly from crystal report.

you have to write text file manually feed spaces between fields

tips (use courier new fonts, once set printer settings make it default printer, from code no need to set printer properties every time)

for printing,
refer link
Sourav Sarkar-SS 30-Aug-12 10:15am
I'm not using vb
I'm using c#. please refer me in that.
How my sql table data went to notepad without exporting?
aarti meswania 30-Aug-12 12:12pm
language doesn't matter you can easily convert your code block in c# online vb to C# code converters are available.
for write data in notepad you can take guideline using google search
Sourav Sarkar-SS 30-Aug-12 12:33pm
ok thanks for your kind help and suggesions
aarti meswania 30-Aug-12 12:38pm
most welcome :)
Praveen21212 11-May-13 5:17am
Hi Aarti,

I am new to notepad printing, I have used crystal reports. Now I want to print on a roll thermal paper which is 3" inch wide. I have gone through the link which you have provided above but that example is accepting text from textbox but I want to create a formatted bill with heading,column heading with dynamic genaerated values. So how to achieve that ?
Thank you.
Aarti Meswania 14-May-13 2:00am
it's long way to go if trying to do with notepad...
if printer is compatible to print crystal report then just set page to custom size and give desired height - width to page.
Praveen21212 18-May-13 2:47am
how to set height for a paper roll ? number of items in the invoice will decide the height.
Aarti Meswania 20-May-13 0:43am
if it's crystal report then set paper hieght & width using page setting
if it's note pad file then manually add remained new lines for eg. if want total 16 lines and you have 12 then add 4 new lines in notepad file using code
Praveen21212 20-May-13 11:39am
Thanks for your help!!!
It's all related to printer. I got that printer and just created a crystal report of 80 mm width and set default printer as thermal one. Done at last!!!
Aarti Meswania 21-May-13 0:27am
good Congrates! :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 31 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100