Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have a bill format made thorough crystalreports where the page width is 4 inch and height is dynamic[I make it 2 inch, I don't know how to make it dynamic].
printer is TVS RP-45 Justbill printer.
printer is wasting lots of paper by ejecting paper after printing,
please suggest the way to stop the paper waste.
Any other way except crystalreporting will be helpful for me.
My Code is wrtten in c#2.0 winforms, database sql server 2005.
stucture of my report is
Report Header Section
                      Bill no : 101
______________________________________________
Detail Section
Item Code               Qty           Amount
[ItemCode]             [Qty]         [Amount]
______________________________________________
Report Footer Section
Grand Total                      [GrandTotal]
______________________________________________



My three section is taking around 2 inch height so I set the Height of the paper to 2 inch,
But still lots of paper is wasted. Paper height is now multiply by 2 if there is more than 1 item.
[My Paper is a Roll Paper where Height is not fixed, it should depends on No. of Item to be sold]

Whatever might be the way, but I need to print the bill without wasting any paper.
Please Please Please help!
Posted
Updated 4-Sep-12 12:40pm
v6
Comments
Sandeep Mewara 4-Sep-12 15:40pm    
Not clear on what are you trying to share and seek help for technically!
[no name] 4-Sep-12 16:46pm    
I am talking about extra paper ejecting by printer after printing task.
After printing the actual document printer eject some extra paper that paper go waste.
I have modified the question

1 solution

> open notepad doc copy paste below text
Report Header Section
                      Bill no : 101
______________________________________________
Detail Section
Item Code               Qty           Amount
[ItemCode]             [Qty]         [Amount]
______________________________________________
Report Footer Section
Grand Total                      [GrandTotal]
______________________________________________

> set font 'courier new'
> open printer settings set papersize & printer
check paper is wasting or not

It will definitely work in text document


create bill dynamically,
C#
billstr= feedcutstr("heading",36,right) + vbnewline; //create feedcutstr function in which you paas string and width & alignment as per that it will feed characters with spaces so string will be become 36 characters
e.g input "headings" output -> "             headings               "

billstr+= feedcutstr("--------------------------------------",36,right) + vbnewline;
for(i=0;i<dtbill.rows.count;i++)>
   {
        if (i==0)
        {  
            billstr += feedcutstr("ItemCode",20,Left) + feedcutstr("Qty",5,right) + feedcutstr("Amount",11,right)+ vbnewline; 
            billstr+= feedcutstr("--------------------------------------",36,right) + vbnewline;
        }
        billstr += feedcutstr(dtbill.rows[i]["itemcode"],20,Left) 
        billstr += feedcutstr(dtbill.rows[i]["Qty"],5,right) 
        billstr += feedcutstr(dtbill.rows[i]["Amount"],11,right) + vbnewline;
   }


// now, write bill str in text file
C#
StreamWriter sw = new StreamWriter("D:\\Test.txt");
//Write a line of text
sw.WriteLine(billstr);
//Close the file
sw.Close();


//then print notepad file(your bill)
C#
objProcess.StartInfo.FileName = "D:\\test.txt";
                    objProcess.StartInfo.Verb = "Print";
                    objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    objProcess.StartInfo.UseShellExecute = true;
                    objProcess.Start();


Happy coding!
:)
 
Share this answer
 
Comments
[no name] 5-Sep-12 12:24pm    
Thank you so much.
I will try and let you inform about this.
But there are couple of question
1. open printer settings set papersize & printer
[is it for notepad and how to do this? and if I set the pa[er size again then will the same thing will happend like in crystal report?]
2. Whenever I print a notepad file directly from notepad it says
[Page too small to print one line
Try printing using smaller font]

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