File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Need help in passbook printing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help in passbook printing" Watch "Need help in passbook printing" New topic
Author

Need help in passbook printing

raghu kalachar
Greenhorn

Joined: Aug 29, 2010
Posts: 10
Hi,
First of all sorry for long question.i have a application where I need to write java code passbook printing.so here is the question.
Suppose I have 10 lines per page and it is divided into 2 array list of 5 each.
I know last printed line and page no,no of record to be printed,start line no.
If I am printing from 1st line with 10 record then first five records need to be inserted to first array list and remaining 5 records need to inserted to second array list.
One more scenario:
Suppose if 3 records are already printed and there are 3 more records need to be printed then 2 record need to inserted into first array list and remaining 1 record need to be inserted into 2nd array list.

Note: this should work if no of lines per page is 9(for odd numbers)

here is the sample program: this works only for even no of lines

// after this I will if no of folds is greater than one or not then there are many if else conditions which is not good to put too many conditions.so please help in this.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

raghu kalachar wrote:First of all sorry for long question.i have a application where I need to write java code passbook printing.so here is the question...

It's difficult to give specific information, since you've provided us with very little info (including a Java class that actually compiles).

However, I think you're getting a bit bogged down in the minutiae of HOW you're going to do this, so my advice would be:
1. Back off a bit, and StopCoding (←click).
2. Think about what printing a passbook (I assume this is for a bank or somesuch) entails.

In all the cases I've seen (including my local Building Society), they have a printer specially designed for the task, so it's quite possible that all this formatting stuff (number of lines per page, how far it got last time, etc) is actually handled by the printer. All a teller needs to do is open the book to the last page and bang it in - possibly more than once if there's a pile of stuff to print.

However, assuming that this is a class exercise, and you do need to do this stuff, the tasks as I see it are as follows:
1. Get an account transaction.
2. Format it for your passbook.
3. Print it.
4. Mark it as "printed", so that it's not printed again.
and for your Passbook class (I assume you have one):
1. Determine what the last line # printed was.
2. Work out whether it was the last line on a page.
3. Work out what page it was on (and if Step 2 returned 'true', add 1 to it).
4. Work out whether that page is on the left or right.
5. Tell the printer where to start printing.

Beyond that, I can't give much other advice except to work it all out ON PAPER before you write a single line of Java code.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
raghu kalachar
Greenhorn

Joined: Aug 29, 2010
Posts: 10
Thanks for your interest winston.For your kind information I have already have working code which prints passbook line by line and in database i am keeping track of no of lines printed and no of pages.But my current requirement is to print in different format.(horizontal format-where there will be fold in the middle of passbook and passbook lines printing need to be printed above and below the fold)

Formatting the passbook data as per horizontal format is challenging here.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

raghu kalachar wrote:But my current requirement is to print in different format.(horizontal format-where there will be fold in the middle of passbook and passbook lines printing need to be printed above and below the fold)
Formatting the passbook data as per horizontal format is challenging here.

No doubt. I'm not even sure I understand it. Are you saying that you also have to print the characters rotated by 90 degrees? Or do you just stick the passbook in "end on" as opposed to the normal way?

Winston
raghu kalachar
Greenhorn

Joined: Aug 29, 2010
Posts: 10
Ha..ha...I don t need to print characters rotated by 90 degrees.Any how passbook need to be sticked to system for printing.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

raghu kalachar wrote:Any how passbook need to be sticked to system for printing.

Yes, but HOW?

If you're printing across the page, the book is presented to the printer just like a normal book, and it will deal with the spacing for each page (left or right). If you're talking about presenting the book end (or sideways) on and printing lines so that they look vertical when looking at the thing like a normal book, then presumably you have to skip the page divide. If that's the case, my advice would be to use some control-feed character that the printer recognises rather than "blank lines"; but TBH I still don't know what your actual problem is.

I suggest you describe it. In detail, including diagrams if need be.

Winston
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in passbook printing