I have a simple XML that demonstrates a problem with keeptogether.  It doesn't use tables as does the other example mentioned in this list.  The following XML
 
  <paragraph indentationleft="20">
paragraph 1
  </paragraph>
  <paragraph keeptogether="true" indentationleft="20">
paragraph 2
  </paragraph>
  <paragraph indentationleft="20">
paragraph 3
  </paragraph>
 
produces
 
paragraph 1
     paragraph 2
     paragraph 3
 
If I put keeptogethers on all the paragraphs or remove them completely, all of the paragraphs indent correctly. 
 
I'm using a simple JSP to display the PDF.  Here it is:
 
<%@ page import="java.io.*" %>
<%@ page import="com.lowagie.text.*" %>
<%@ page import="com.lowagie.text.pdf.*" %>
<%@ page import="com.lowagie.text.xml.*" %>
<%@ page import="javax.xml.parsers.*" %>
 
<%
final String TEMPLATE_START = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><itext>";
final String TEMPLATE_END = "</itext>";
 
// this java will only execute if there is a piece of text in the
// form parameter.
String text = request.getParameter("text");
if (text != null) {
 String templateText = TEMPLATE_START + text + TEMPLATE_END;
 char[] buf = templateText.toCharArray();
 CharArrayReader reader = new CharArrayReader(buf);
    OutputStream oStream = response.getOutputStream();
    response.setContentType("application/pdf");
    out.clear();
    Document document = new Document(PageSize.LETTER, 80, 50, 30, 65);
    PdfWriter.getInstance(document, oStream);
    SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    parser.parse(new org.xml.sax.InputSource(reader), new SAXiTextHandler(document));
 return;
} // if text passed in
%>
 
<html><body>
  <form name="f" action="" method="get">
   <p>Test PDF using iText XML<br>
   <textarea name="text" cols="80" rows="20"></textarea><br>
   <input type="submit"/>
  </form>
 </body></html>
 
 
Any suggestions?
 
 
 
Shawn Gordhamer
952-594-6910
 
 
This e-mail may contain confidential or privileged
information. If you think you have received this e-mail in error,
please advise the sender by reply e-mail and then delete this
e-mail immediately. Thank you. Aetna
-------------------------------------------------------------------------
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

Reply via email to