Your fix was accepted, thank you.
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Lewis, Cory (Genworth)
> Sent: Thursday, February 22, 2007 9:57 PM
> To: [email protected]
> Subject: Re: [iText-questions] Premature EOF in Jpeg.Java
> processParameters
>
> Hi all,
>
> I was able to fix Jpeg.java so that it processed my
> images. I have included the modified class for your
> inspection, to see if perhaps it could be included with the
> general release. Please let me know if something I've done is
> incorrect.
>
> I will attempt to explain my changes.
>
> from processParameters()
>
> if (marker == M_APPE) {
> len = getShort(is) - 2;
> byte[] byteappe = new byte[len];
> for (int k = 0; k < len; ++k) {
> byteappe[k] = (byte)is.read();
> }
> if (byteappe.length > 12) {
> String appe = new
> String(byteappe, 0, 5, "ISO-8859-1");
> if (appe.equals("Adobe")) {
> invert = true;
> }
> }
> continue;
> }
>
> where I changed the 2nd line to have a - 2, and added the continue.
>
> Previously, with my "bad" image, it would process the image
> along until it came to the FF EE marker, defined as M_APPE
> here. getShort would return 121, and it would read those into
> byteappe[], then continue through the code, and skip
> *additional* bytes into the stream(not depicted here).
>
> In the images I've been having problems with, the SOI marker
> (FFC0) was the next marker after FFEE. The 121 would take it
> just past this marker. The -2 would instead set the next
> read operation right at FF.
>
> After the above block, there was the check for VALID_MARKER
> or any of the NOPARAM_MARKERS. Since 0xEE is neither of
> these, it would then perform a skip and go even further past
> the FFC0 marker. The continue skips(no pun intended) over
> this unnecessary skip.
>
> The cause of my premature EOF earlier was that it was getting
> into the actual image content, and coming across FF00's,
> which it interpreted as markers it should skip.
>
> Let me know if you have any questions or concerns.
>
> Thanks,
> Cory
>
>
>
>
>
> ________________________________
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Lewis, Cory (Genworth)
> Sent: Thursday, February 22, 2007 8:58 AM
> To: [email protected]
> Subject: Re: [iText-questions] Premature EOF in
> Jpeg.Java processParameters
>
>
> I've found another jpeg that exhibits the same issue.
> It comes from the same source as the previous one, but I do
> have images from that source that work without issue.
>
> Thanks,
> Cory
>
>
> ________________________________
>
> From:
> [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Lewis, Cory (Genworth)
> Sent: Wednesday, February 21, 2007 11:00 AM
> To: [email protected]
> Subject: [iText-questions] Premature EOF in
> Jpeg.Java processParameters
>
>
> Hi all,
>
> I have a jpeg that's causing problems. I'm
> not sure if it's borderline invalid or if there is an issue
> with the code, so here I am.
>
> I call Image.getInstance with a byte[], and get
> the following stack trace:
>
> java.io.IOException: Premature EOF while reading JPG.
> at
> com.lowagie.text.Jpeg.processParameters(Jpeg.java:265)
> at com.lowagie.text.Jpeg.<init>(Jpeg.java:176)
> at com.lowagie.text.Image.getInstance(Image.java:475)
> at
> com.gefa.services.imaging.core.shared.pdf.iTextPDFConverter.ad
> dGenericPage(iTextPDFConverter.java:216)
> at
> com.gefa.services.imaging.core.shared.pdf.iTextPDFConverter.co
> nvertToPDF(iTextPDFConverter.java:80)
>
> I pulled the code out(processParameters from
> Jpeg.java) so I could add some debugging stuff, and got the following:
>
> current shows the current byte from is.read()
> using Integer.toHexString(), available shows what
> is.available() reports.
>
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O length: 11148
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O current: ff available: 11145
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O first pass
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O current: ff available: 11127
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O skipping: 26
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O current: ff available: 11097
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O current: ff available: 10974
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O current: ff available: 10851
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:299 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10728
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10605
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10482
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 119
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10359
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O M_APPE
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 9
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10223
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 130
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10089
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 29
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 10056
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 179
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O current: ff available: 9873
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:314 EST] 00000037 SystemOut
> O skipping: 6
> [2/21/07 10:32:04:330 EST] 00000037 SystemOut
> O current: 8b available: 9863
> [2/21/07 10:32:04:330 EST] 00000037 SystemOut
> O current: ca available: 9862
> ...
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O current: 5a available: 8969
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O current: 60 available: 8968
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O current: 81 available: 8967
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O current: 69 available: 8966
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O current: ff available: 8965
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O noparam_marker
> [2/21/07 10:32:04:861 EST] 00000037 SystemOut
> O skipping: 26200
> [2/21/07 10:32:04:877 EST] 00000037 SystemOut
> O current: ffffffff available: 0
> [2/21/07 10:32:04:877 EST] 00000037 LoggerBean
> E com.triteksol.util.LoggerBean error Error creating
> document: Premature EOF while reading JPG.
>
> java.lang.Exception: Premature EOF while reading JPG.
> at
> com.gefa.services.imaging.core.shared.pdf.iTextPDFConverter.pr
> ocessParameters(iTextPDFConverter.java:403)
> at
> com.gefa.services.imaging.core.shared.pdf.iTextPDFConverter.co
> nvertToPDF(iTextPDFConverter.java:78)
> at
> com.gnw.imaging.imagetype.impl.GenericImage.assemble(GenericIm
> age.java:64)
>
>
> At byte 887 it hits FF, then decides to skip
> 26200 bytes, which takes it well past the end of the array,
> and the next time through the while loop throws the premature
> EOF. That noparam_marker is right before the skip in the
> else if (markertype
> <javascript:searchRef('markertype')> != NOPARAM_MARKER
> <javascript:searchRef('NOPARAM_MARKER')> )
> block.
>
> I am attaching the offending jpeg, but I'm not
> sure if it will come across. If it doesn't and anyone wants
> it please email me directly.
> I have no problem viewing the jpeg, so like I
> said, I'm not sure if it's borderline invalid or there is a
> code issue.
>
> I'm using 1.4.8.
>
> Any help or insight is greatly appreciated.
>
> Thanks,
> Cory
>
> Cory Lewis
> Genworth Financial
> IT Systems Specialist
> (434)522-2120
>
>
>
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.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/