PDF files can't be compared byte by byte. Testing PDF files is very hard and
it's not the font order that is going to make any difference.
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of JRudolph
> Sent: Thursday, August 28, 2008 12:00 PM
> To: [email protected]
> Subject: Re: [iText-questions] [patch] output PDF fonts in
> predictable order
>
>
> Hi!
>
> Well, I just stumbled about the same problem. While it is arguably bad
> practice to compare binary files byte by byte for testing, it
> is at least
> the first best option you come up with. (Do you know any better?)
>
> I think we can agree on caring about compability as far as
> possible and not
> introducing somewhat specific changes. BUT: IMO a tool
> generating (binary)
> files should do this in a deterministic and reproducible way,
> at least in
> the cases where no explicit non-uniqueness is wanted (like the ID or
> timestamps). However, even for this cases it would be nice if
> you could
> explicitly control these fields.
>
> Johannes
>
>
> Paulo Soares wrote:
> >
> > Well, I could ask you why should a fix be applied just to
> ease your unit
> > testing, as if the font order was any obstacle. I wonder why the
> > dictionary
> > keys shouldn't also be ordered, you forgot that one. The
> fix doesn't add
> > anything to iText, makes it slower, wastes memory, is
> another lock on jdk
> > 1.4 when many are still using jdk 1.3 and your reasoning
> that the fonts
> > must
> > be ordered to be tested is flawed.
> >
> > Paulo
> >
> > ----- Original Message -----
> > From: "Chad Loder" <[EMAIL PROTECTED]>
> > To: "Post all your questions about iText here"
> > <[email protected]>
> > Sent: Wednesday, August 27, 2008 8:31 PM
> > Subject: Re: [iText-questions] [patch] output PDF fonts in
> predictable
> > order
> >
> >
> > Hi Paulo. Can you please elaborate on why the fix won't happen?
> >
> > Thanks,
> > c
> >
> > On Wed Aug 27/2008 @ 12:08:P +0100 asdasd, Paulo Soares wrote:
> >> That fix won't happen, change your testing or your iText code.
> >>
> >> Paulo
> >>
> >> > -----Original Message-----
> >> > From: [EMAIL PROTECTED]
> >> > [mailto:[EMAIL PROTECTED] On
> >> > Behalf Of Chad Loder
> >> > Sent: Wednesday, August 27, 2008 3:09 AM
> >> > To: [email protected]
> >> > Subject: [iText-questions] [patch] output PDF fonts in
> >> > predictable order
> >> >
> >> > One of our issues when unit testing our PDF generation code
> >> > is that iText
> >> > creates PDFs with fonts in an unpredictable order. This makes
> >> > it impossible
> >> > to simply compare checksums of itext-generated PDF files from
> >> > one change
> >> > to the next.
> >> >
> >> > This is due to one particular use of HashMap internally
> >> > within the PdfWriter
> >> > class. Replacing this use of HashMap with LinkedHashMap
> >> > solves the problem
> >> > because LinkedHashMap iterates over its entries in the
> order they were
> >> > inserted. LinkedHashMap was added in JDK 1.4 so it will be
> >> > compatible with
> >> > the 1.4 requirement that itext has.
> >> >
> >> > The following diff fixes the issue and has been tested.
> >> >
> >> > Index: itext/java/com/lowagie/text/pdf/PdfWriter.java
> >> >
> ===================================================================
> >> > diff -u -p -r1.1.1.9 PdfWriter.java
> >> > --- itext/java/com/lowagie/text/pdf/PdfWriter.java 6 Jun
> >> > 2007 23:11:39 -0000 1.1.1.9
> >> > +++ itext/java/com/lowagie/text/pdf/PdfWriter.java 26
> >> > Aug 2008 23:22:06 -0000
> >> > @@ -57,6 +57,7 @@ import java.util.ArrayList;
> >> > import java.util.HashMap;
> >> > import java.util.HashSet;
> >> > import java.util.Iterator;
> >> > +import java.util.LinkedHashMap;
> >> > import java.util.Map;
> >> > import java.util.TreeMap;
> >> > import java.util.TreeSet;
> >> > @@ -1842,7 +1843,7 @@ public class PdfWriter extends DocWriter
> >> > // [F3] adding fonts
> >> >
> >> > /** The fonts of this document */
> >> > - protected HashMap documentFonts = new HashMap();
> >> > + protected LinkedHashMap documentFonts = new LinkedHashMap();
> >> >
> >> > /** The font number counter for the fonts in the
> document. */
> >> > protected int fontNumber = 1;
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php