Share

iTextSharp

Tracker: Bugs

5 Error parsing images in HTML files - ID: 1819614
Last Update: Comment added ( psoares33 )

I am currently using the iTextSharp port to generate HTML to PDF and have
found a slight bug and have one suggestion....

When progressing images in HTML the SAX parser checks if the stack contains
a section, chapter or cell. In most cases this is invalid as images will be
inside P's or DIV's and therefore can I recommend you include Paragraphs in
this or statement (SAXiTextHanderl.java - line 502

On a related note, if the image url is relative i.e "/image/test" an
exception is thrown as the file is recognised. Would it be wise to prefix
urls beginning with "/" with the current application directory (or html
file path root). I have done so in my itextsharp build but perhaps it
should be an option


Anthony Main ( tigermain ) - 2007-10-24 22:06

5

Closed

None

Nobody/Anonymous

None

None

Public


Comments ( 2 )

Date: 2009-12-07 09:52
Sender: psoares33Project Admin

Those classes were removed.


Date: 2008-05-30 07:22
Sender: nobody

Logged In: NO

I got the same problem when my html-markup contains images in div-tags.
The problem is method AddImage in ITextHandler. In this case the program
runs through the else branch.
I'didd't understand why, but there a new stack is built by moving the
items from the main stack (stack) to the new stack (newstack). The error
occurs because the while-loop is exited by an exception because the loop
contains executing though stack.Count = 0 because the element we are
searching for is never found.
Because of this the items will never be moved back to the main stack and
all further stack.Pop()-statements will fail.

I changed the while condition to "!(current is Chapter || current is
Section || current is Cell) && stack.Count!=0"
but maybe someone who knows the code better should check this.



Attached File

No Files Currently Attached

Changes ( 3 )

Field Old Value Date By
close_date - 2009-12-07 09:52 psoares33
allow_comments 1 2009-12-07 09:52 psoares33
status_id Open 2009-12-07 09:52 psoares33