Printable and Books

J

Jason Cavett

I am attempting to print from my Java application, and it actually
works very nicely - as long as I only send a single Printable object
to the printer. However, when I try to add multiple Printable objects
to a Book (so I can send the Book to the printer as one print job),
only the first page of each Printable object is printed.

I found a quote online (and I'm pretty sure that the guy who wrote it
is wrong) that says, if you don't know the number of pages when you
append the Printable object to the Book, do this:

book.append(doc, format, Book.UNKNOWN_NUMBER_OF_PAGES);

....and the PrinterJob will use the implemented print function in your
Printable object to determine the number of pages at the time of the
printing. This is exactly what I want. However, every time I do
that, I get an OutOfBoundsException because the Book object can't have
a negative size Vector (UNKNOWN_NUMBER_OF_PAGES = -1). Soooo...I'm
not sure what to do here.

Does anybody have any suggestions? (I'm using Java 5.0.)


Thanks
 
H

Hunter Gratzner

I found a quote online (and I'm pretty sure that the guy who wrote it
is wrong) that says, if you don't know the number of pages when you
append the Printable object to the Book, do this:

book.append(doc, format, Book.UNKNOWN_NUMBER_OF_PAGES);

Why don't you read the Book API documentation to find out what
append() really does, and what other methods Book provides?
 
J

Jason Cavett

Why don't you read the Book API documentation to find out what
append() really does, and what other methods Book provides?

Maybe my question was misstated...

How do I print a lot of pages (when I don't know the number of pages
ahead of time) but only send one job to the printer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top