During flattening, iText stores a page's annotation in a HASH MAP. The
Z-order the fields are in when they are flattened is essentially random.
You were lucky they happened to be in the right order in 5. It would
appear that the hashing algorithm has changed, or that the version is
part of the hash.
In either case, the z-order (depth order) of the flattened fields has
changed. This is a known bug in iText. (okay, *I* know about it, but I
don't think there's a bug for it on sourceforge). You have three
options:
1) Draw your "background" annotations directly into the page's contents
in the first place. This may not be an option depending on where your
PDFs are coming from.
2) Wait for someone else to fix this bug. You could be waiting a long
time.
3) Fix it yourself. In PdfStamperImpl.flatFields(), You'd need to
change the hash map to a sorted map, and use a custom comparison to sort
them in Z-order.
Actually, that doesn't sound so hard.
And Bruno already beat me to it. As per a suggestion from Jesse Barnum,
AcroFields now stores all its fields in a LinkedHashMap. Such maps keep
track of the order in which their keys were inserted, and use that for
their iteration. Keys (field names) are added in Z-order (their order
in the annotation array of the pages). Problem solved. Trivial (O(1))
overhead (except maybe for O(n) deletion?), and iteration should
actually be a tad faster.
This fix was released in 5.0.3. Enjoy.
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: Nitin Gupta [mailto:[email protected]]
Sent: Friday, July 23, 2010 2:51 AM
To: [email protected]
Subject: Re: [iText-questions] Problem with different version of Java
The attached code is the file which I am using to make templates in the
first place.
From: Nitin Gupta [mailto:[email protected]]
Sent: Friday, July 23, 2010 2:27 AM
To: '[email protected]'
Subject: Problem with different version of Java
Hi All,
I am making use of the acro form fields to make use of template pdfs to
produce new pdf documents. However, I am getting different output on
different Java versions.
I need the output that I am getting on Java 5 but my target Java version
is Java 6.
I am attaching the code as well as the resulting pdf file which I am
getting on the respective Java version.
Please help how I can address this issue.
Regards
Nitin
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.851 / Virus Database: 271.1.1/3009 - Release Date: 07/22/10
11:36:00
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
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/