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
Hunter Gratzner - 10 Oct 2007 20:20 GMT
> 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?
Jason Cavett - 10 Oct 2007 22:16 GMT
> > 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
[quoted text clipped - 4 lines]
> 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?