Harlan Messinger wrote:
> I'm interested in generating a PDF containing a set of cards half of 
> U.S. standard letter size. For some reason, my HP printer prints very 
> slowly when I print to paper of any size other than letter, so what I'd 
> like to do is print two cards on each full letter-size card stock in 
> landscape orientation, so that I can then slice the pile of cards in 
> half. After I'm done, the cards should be in a particular order, and it 
> will be easiest if I can do it as follows:
> 
> 1. Generate the cards as virtual pages, without adding them to the 
> document, so that when I've finished that I can see how many I have.

Create a PDF file that is written to a ByteArrayOutputStream.
Then get the byte[] from that stream and feed it to a PdfReader object.
Ask the reader object for the page count.

> 2. If I have N cards (where N is an even number; if N is odd, then I'll 
> just add a blank card on the end), I want to write card1 to the left 
> side of the first full-size page of the PDF and card (N/2 + 1) to the 
> right side, card 2 and card (N/2 + 2) to the second page, and so on, so 
> that card (N/2) and card N are both on the final sheet.

Now create a second PDF file that is written to a FileOutputStream.
Create PdfImportedPage instances using the reader that has access
to the first document that was created in memory.
Scale the imported pages down to half their size before you add
them to the second document.

> I tried to find a suitable generic container element for this purpose 
> but I was unsuccessful. Is there a solution?

Piece of cake.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to