Mit freundlichen Gr��en
Klaus Fleischer
IZB SOFT - S52
* 0911/3269-344
* IZB SOFT - S�dwestpark 108 , 90449 N�rnberg
* [EMAIL PROTECTED]
-----Urspr�ngliche Nachricht-----
Von: Fleischer, Klaus
Gesendet: Mittwoch, 12. Mai 2004 18:32
An: 'Paulo Soares'
Betreff: AW: [iText-questions] first newlines missing, first chunks
overprinted
Wichtigkeit: Hoch
Dear Mr. Soares
thanks a lot for the quick answer.
But if youd don't support chunks at the document level,
you should change in line 354 in the method handleStartingTags(..) of
* $Id: SAXiTextHandler.java,v 1.42 2002/08/23 10:45:34 blowagie Exp $
document.add(Chunk.NEWLINE);
to
current = new Paragraph(Chunk.NEWLINE);
stack.push(current);
which doesn't work either.
Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE itext SYSTEM "./itext.dtd" >
<itext>
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<paragraph leading="30" size="20">Title - Page</paragraph>
<chapter>
<title>chapter</title>
<sectioncontent>res est arduissima, vincere
naturam</sectioncontent>
</chapter>
</itext>
By the way, there is another problem, if you combine Chunks and Chapters;
the chunks are wrapped into a Paragraph, and so it works, but the order is
changed.
Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE itext SYSTEM "./itext.dtd" >
<itext>ߐ
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<newline/>
<paragraph leading="30" size="20">Title - Page</paragraph>
<chapter>
<title>chapter 1</title>
<sectioncontent>res est arduissima, vincere
naturam</sectioncontent>
</chapter>
Haec verba in finem saltant.
<chapter>
<title>chapter 2</title>
<sectioncontent>in aspectu virginis mentem esse
puram</sectioncontent>
</chapter>
</itext>
So the lines 683 - 686 in the method handleEndingTags(..) of
* $Id: SAXiTextHandler.java,v 1.42 2002/08/23 10:45:34 blowagie Exp $
if (Chapter.isTag(name)) {
document.add((Element) stack.pop());
return;
}
should be changed to
if (Chapter.isTag(name)) {
Chapter chapter = (Chapter) stack.pop();
try {
while (true) {
Element element = (Element)
stack.pop();
try {
TextElementArray previous =
(TextElementArray) stack.pop();
previous.add(element);
stack.push(previous);
}
catch(EmptyStackException es) {
document.add(element);
}
}
}
catch(EmptyStackException ese) {
// empty on purpose
}
document.add(chapter);
return;
}
Maybe the better and easier way is to delete
chunk and newline from the element list of itext
in line 60 of
$Id: itext.dtd,v 1.12 2003/09/06 09:37:52 blowagie Exp $
With best regards
Klaus Fleischer
IZB SOFT - S52
* 0911/3269-344
* IZB SOFT - S�dwestpark 108 , 90449 N�rnberg
* [EMAIL PROTECTED]
> -----Urspr�ngliche Nachricht-----
> Von: Paulo Soares [mailto:[EMAIL PROTECTED]
> Gesendet: Dienstag, 11. Mai 2004 12:02
> An: Fleischer, Klaus; [EMAIL PROTECTED]
> Betreff: RE: [iText-questions] first newlines missing, first chunks
> overprinted
>
>
> Document.add(Chunk) does not change the document leading. Put your
> chunks inside a Paragraph.
>
> Best Regards,
> Paulo Soares
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On
> > Behalf Of Fleischer, Klaus
> > Sent: Monday, May 10, 2004 5:08 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: [iText-questions] first newlines missing, first
> > chunks overprinted
> > Importance: High
> >
> > Problem:
> > If a Document begins with chunks or Chunk.NEWLINE,
> > the newlines will not be printed, the chunks will
> > be overprinted.
> >
> > <<Test examples.java>>
> > Patch:
> > The reason of that behaviour is that in line 423 of
> > * $Id: PdfDocument.java,v 1.174 2004/02/07 10:28:40
> > blowagie Exp $
> > leading is initiated with 0.
> >
> > A quick solution is to insert after line 1192
> > case Element.CHUNK: {
> > the following line:
> > leading = ((Chunk) element).font().leading(1.5f);
> >
> > (The more beautiful solution, to initiate leading with
> > Float.NaN and do the setting here conditionally, does
> > not work, (at least not so quick) because the
> > carriageReturn(); in line 2077 of initPage(), which is
> > called by open(), will try to insert a
> > PdfLine with the height Float.NaN and I don't know,
> > whether there are more side effects.)
> >
> >
> >
> > With kind regards
> > Klaus Fleischer
> >
> >
> >
>
-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions