  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | -none- | -none- 2007-08-21 - By Michael McCall
Back To Whom It May Concern:
I am currently developing a web application that uses Spring Framework and iText to take in values (through a series of forms) and generate a PDF letter from them.
The length of the body of my letter is dynamic, but I want the closing of my letter to always stay together on one page. I have a Java class with the following code in it:
String x = firstName + " " + lastName + "\n" + title;
Paragraph closing = new Paragraph("Sincerely,\n\n\n\n" + x + "\nEndeca Technologies, Inc.");
closing.setKeepTogether(true);
document.add(closing);
Simply put: it's not working. As the document changes based on user input, the paragraph often splits to two pages, putting "Sincerely," at the end of one page and stranding the rest of the text on the following page. I even printed the value of "closing.getKeepTogether()" in the PDF to double-check, and it does in fact say "true."
I am not having any other problems with my app currently, so I don't think there are any configuration problems that might be behind this. I looked through the documentation and the mailing list archives, and I could not find any examples or related problems. I've seen your "How deep is blue?" FAQ, so I hate to ask such a vague question, but...why doesn't it work? Really, I am looking for any suggestions you might have or for you to tell me that it's actually just a bug you're fixing for the next version.
Thanks.
__ ____ ____ ____ ____ ____
Michael McCall IT Intern T 617.674.6330 M 860.967.6178 mmccall@(protected)
Endeca 101 Main Street, 14th Floor
Cambridge, MA, 02142 www.endeca.com <http://www.endeca.com/>
find / analyze / understand
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft -com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1= "urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC -html40">
<head> <meta http-equiv=Content-Type content="text/html; charset=us-ascii"> <meta name=Generator content="Microsoft Word 11 (filtered medium)"> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PostalCode"/> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"/> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"/> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="Street"/> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="address"/> <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"/> <!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-compose; font-family:Arial; color:windowtext;} @(protected) Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--> </head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>To Whom It May Concern:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>I am currently developing a web application that uses Spring Framework and iText to take in values (through a series of forms) and generate a PDF letter from them.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>The length of the body of my letter is dynamic, but I want the closing of my letter to always stay together on one page. I have a Java class with the following code in it:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>String x = firstName + <font color=blue><span style='color:blue'>“ “</span></font> + lastName + <font color=blue><span style='color:blue'>“\n“</span></font> + title;<o:p ></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial; color:black'>Paragraph closing = </span></font><b><font size=2 color="#993366" face=Arial><span style='font-size:10.0pt;font-family:Arial;color:#993366; font-weight:bold'>new</span></font></b><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'> Paragraph(</span></font ><font size=2 color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial; color:blue'>"Sincerely,\n\n\n\n"</span></font><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial; color:black'> + x + </span></font><font size=2 color=blue face=Arial><span style='font-size:10.0pt;font-family:Arial;color:blue'>"\nEndeca Technologies, Inc."</span></font><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>);</span></font><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><o:p></o:p>< /span></font></p>
<p class=MsoNormal style='text-indent:.5in;text-autospace:none'><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial; color:black'>closing.setKeepTogether(</span></font><b><font size=2 color="#993366" face=Arial><span style='font-size:10.0pt;font-family:Arial; color:#993366;font-weight:bold'>true</span></font></b><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>);< /span></font><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><o:p></o:p>< /span></font></p>
<p class=MsoNormal style='text-indent:.5in'><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black' >document.add(closing);</span></font><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><o:p></o:p>< /span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Simply put: it’s not working. As the document changes based on user input, the paragraph often splits to two pages, putting “Sincerely,” at the end of one page and stranding the rest of the text on the following page. I even printed the value of “closing .getKeepTogether()” in the PDF to double-check, and it does in fact say “true.”<o:p></o :p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>I am not having any other problems with my app currently, so I don’t think there are any configuration problems that might be behind this. I looked through the documentation and the mailing list archives, and I could not find any examples or related problems. I’ve seen your & #8220;How deep is blue?” FAQ, so I hate to ask such a vague question, but…why doesn’t it work? Really, I am looking for any suggestions you might have or for you to tell me that it’s actually just a bug you’re fixing for the next version.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Thanks.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><b><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black;font-weight:bold'>__ ____ __ ____ ____ ____ __</span></font></b><o:p></o:p></p>
<p class=MsoNormal><b><font size=2 color="#f06a00" face=Arial><span style='font-size:10.0pt;font-family:Arial;color:#F06A00;font-weight:bold' >Michael McCall</span></font></b><font face=Arial><span style='font-family:Arial'><br> </span></font><font size=2 face=Arial><span style='font-size:10.0pt;font-family: Arial'>IT Intern<br> <font color=gray><span style='color:gray'>T 617.674.6330</span></font></span>< /font><font face=Arial><span style='font-family:Arial'><br> </span></font><font size=2 color=gray face=Arial><span style='font-size:10.0pt; font-family:Arial;color:gray'>M 860.967.6178</span></font><font face=Arial><span style='font-family:Arial'><br> </span></font><font size=2 color=gray face=Arial><span style='font-size:10.0pt; font-family:Arial;color:gray'><a href="mailto:mmccall@(protected)">mmccall @(protected)</a></span></font><font face=Arial><span style='font-family:Arial'><br> <br> </span></font><b><font size=2 color="#f06a00" face=Arial><span style='font-size:10.0pt;font-family:Arial;color:#F06A00;font-weight:bold' >Endeca</span></font></b><font face=Arial><span style='font-family:Arial'><br> </span></font><st1:Street w:st="on"><st1:address w:st="on"><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial; color:gray'>101 Main Street</span></font></st1:address></st1:Street><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial; color:gray'>, 14th Floor</span></font><o:p></o:p></p>
<p class=MsoNormal><st1:place w:st="on"><st1:City w:st="on"><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial; color:gray'>Cambridge</span></font></st1:City><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial;color:gray'>, <st1 :State w:st="on">MA</st1:State>, <st1:PostalCode w:st="on">02142</st1:PostalCode>< /span></font></st1:place><font face=Arial><span style='font-family:Arial'><br> </span></font><font size=2 color="#f06a00" face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:#F06A00'><a href="http://www.endeca.com/"><font color="#f06a00"><span style='color:#F06A00'>www.endeca.com</span></font></a>< /span></font><font face=Arial><span style='font-family:Arial'><br> <br> </span></font><b><font size=2 color=gray face=Arial><span style='font-size: 10.0pt;font-family:Arial;color:gray;font-weight:bold'>find </span></font></b><b ><font size=2 color="#f06a00" face=Arial><span style='font-size:10.0pt;font-family: Arial;color:#F06A00;font-weight:bold'>/</span></font></b><b><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial; color:gray;font-weight:bold'> analyze </span></font></b><b><font size=2 color="#f06a00" face=Arial><span style='font-size:10.0pt;font-family:Arial; color:#F06A00;font-weight:bold'>/</span></font></b><b><font size=2 color=gray face=Arial><span style='font-size:10.0pt;font-family:Arial;color:gray; font-weight:bold'> understand</span></font></b><o:p></o:p></p>
</div>
</body>
</html>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |