Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
JTable to PDF without any pagination

JTable to PDF without any pagination

2007-07-25       - By chandrajeet padhy

 Back
Reply:     1     2     3     4  

Sorry  Clair W. Cabal about overlapping a previous thread. I just did a quick
reply from my inbox.

Mark Storer, Thanks for the reply.

1) Try a
different G2D
I didn't understand from this. How do i create a different one?

2) The table perfectly prints. So its not a white one. (Hope u looked at the
attachment. I created that using a PDF print driver from my actual Table. So
the table does exists.)

3)Well its a fresh pdf. I delete any previously existing pdf. How do I set the
PdfTemplate's boundries from actual table boundaries.

Peace n Regards,
Chandrajeet



It looks
like you're running into one of several possible problems:



1) You're
not actually drawing anything.  



Try a
different G2D to test your output.  You may already know the table writes
successfully to your UI or whatever.



2) You're
not drawing anything visible.



White one
white, that sort of thing.  Probably not the issue.



3) You're
drawing outside the visible area.



The page's
boundries are one limitation, but the PdfTemplate's boundries are another.  
If the table is offset vertically greater than it's height, you'll never see it
,
ditto for horizontal/width.



If you were
working with an existing PDF, you'd have to worry about page rotation too...
but
that doesn't apply in this case.

--Mark Storer
 Senior Software Engineer
 
Cardiff.com

#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;


 -- --Original Message-- --
From:
 itext-questions-bounces@(protected)
 [mailto:itext-questions-bounces@(protected)]On Behalf Of
 chandrajeet padhy
Sent: Wednesday, July 25, 2007 8:40
 AM
To: Post all your questions about iText here
Subject:
 Re: [iText-questions] Dynamic content in document header



 Hi
 All,

I want a PDF output of a large JTable without any pagination.
I
 am sending a sample output attached.
Whatever may be the row or column
 count, I want that in a single page. With the cell colors retained.

I
 used the following code: -

       
 Document document = new Document();
       
 table.setVisible(true);
       try
 {          
 
           // step
 2: creation of the
 writer
           
 PdfWriter writer = PdfWriter.getInstance(document, new
 FileOutputStream(FILE_NAME));
           
 
           // step
 3: we open the
 document
           
 document.open();
           
 
           // step
 4: we grab the ContentByte and do some stuff with
 it
           
 
           // we
 create a template and a Graphics2D object that corresponds with
 it
           int w
 =
 table.getWidth();
           
 int h =
 table.getHeight();
           
 PdfContentByte cb =
 writer.getDirectContent();
           
 PdfTemplate tp = cb.createTemplate(w,
 h);
           
 Graphics2D g2 = tp.createGraphics(w,
 h);
           
 tp.setWidth(w);
           
 tp.setHeight(h);
           
 table.paint(g2);
           
 g2.dispose();
           
 cb.addTemplate(tp, 50,
 400);          
 
       
 }
       catch(DocumentException de)
 {
           
 System.err.println(de.getMessage());
       
 }
       catch(IOException ioe)
 {
           
 System.err.println(ioe.getMessage());
       
 }      
 
       // step 5: we close the
 document
       
 document.close();

But this prints absolutely nothing   .

  Thanks

 
 
 Chandrajeet
 Padhy.



 



     
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ______
__ __
Looking for a deal? Find great prices on flights and hotels with Yahoo!
FareChase.
http://farechase.yahoo.com/
<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head>
<body><div style="font-family:times new roman, new york, times, serif;font-size
:12pt"><div><font face="Courier New" size="2"><span class="001041217-25072007"
>Sorry </span></font> Clair W. Cabal <font face="Courier New" size="2"><span
class="001041217-25072007">about overlapping a previous thread. I just did a
quick reply from my inbox.<br><br></span></font><font face="Arial" size="2"
>Mark Storer</font>, Thanks for the reply.<br><font face="Courier New" size="2">
<span class="001041217-25072007"><br><span style="font-weight: bold;">1) </span>
</span></font><font face="Courier New" size="2"><span class="001041217-25072007"
><span style="font-weight: bold;">Try a
different G2D</span><br>I didn't understand from this. How do i create a
different one?<br><br>2) The table perfectly prints. So its not a white one.
(Hope u looked at the attachment. I created that using a PDF print driver from
my actual Table. So the table does exists.)<br><br>3)Well its a fresh pdf. I
delete any previously existing pdf. How do I set the </span></font><font face=
"Courier New" size="2"><span class="001041217-25072007">PdfTemplate's boundries
from actual table boundaries.<br><br>Peace n Regards,<br>Chandrajeet<br></span>
</font><font face="Courier New" size="2"><span class="001041217-25072007"><br>
<br><br>It looks
like you're running into one of several possible problems:</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">1) You
're
not actually drawing anything.&nbsp; </span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">Try a
different G2D to test your output.&nbsp; You may already know the table writes
successfully to your UI or whatever.</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">2) You
're
not drawing anything visible.</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">White
one
white, that sort of thing.&nbsp; Probably not the issue.</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">3) You
're
drawing outside the visible area.</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">The
page's
boundries are one limitation, but the PdfTemplate's boundries are another.&nbsp
;
If the table is offset vertically greater than it's height, you'll never see it
,
ditto for horizontal/width.</span></font></div>
<div><font face="Courier New" size="2"><span class="001041217-25072007"></span>
</font>&nbsp;</div>
<div><font face="Courier New" size="2"><span class="001041217-25072007">If you
were
working with an existing PDF, you'd have to worry about page rotation too...
but
that doesn't apply in this case.</span></font></div>
<p><font face="Arial" size="2">--Mark Storer</font> <br><font face="Arial" size
="2">&nbsp; Senior Software Engineer</font> <br><font face="Arial" size="2">
&nbsp;
Cardiff.com</font></p>
<p><font face="Arial" size="2">#include &lt;disclaimer&gt;</font> <br><font
face="Arial" size="2">typedef std::Disclaimer&lt;Cardiff&gt; DisCard;</font> <
/p>

 <div class="OutlookMessageHeader" dir="ltr" align="left"><font face="Tahoma"
size="2">-- --Original Message-- --<br><b>From:</b>
 itext-questions-bounces@(protected)
 [mailto:itext-questions-bounces@(protected)]<b>On Behalf Of
 </b>chandrajeet padhy<br><b>Sent:</b> Wednesday, July 25, 2007 8:40
 AM<br><b>To:</b> Post all your questions about iText here<br><b>Subject:</b>
 Re: [iText-questions] Dynamic content in document header<br><br></font></div>
 Hi
 All,<br><br>I want a PDF output of a large JTable without any pagination.<br
>I
 am sending a sample output attached.<br>Whatever may be the row or column
 count, I want that in a single page. With the cell colors retained.<br><br>I
 used the following code: -<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 Document document = new Document();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 table.setVisible(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try
 {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
step
 2: creation of the
 writer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 PdfWriter writer = PdfWriter.getInstance(document, new
 FileOutputStream(FILE_NAME));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
step
 3: we open the
 document<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;
 document.open();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
step
 4: we grab the ContentByte and do some stuff with
 it<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // we
 create a template and a Graphics2D object that corresponds with
 it<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
w
 =
 table.getWidth();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 int h =
 table.getHeight();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 PdfContentByte cb =
 writer.getDirectContent();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;
 PdfTemplate tp = cb.createTemplate(w,
 h);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Graphics2D g2 = tp.createGraphics(w,
 h);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 tp.setWidth(w);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 tp.setHeight(h);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 table.paint(g2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
 g2.dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
 cb.addTemplate(tp, 50,
 400);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(DocumentException de)
 {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 System.err.println(de.getMessage());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
 }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(IOException ioe)
 {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 System.err.println(ioe.getMessage());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
 }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // step 5: we close the
 document<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 document.close();<br><br>But this prints absolutely nothing &nbsp; .<br>
 <div>&nbsp;Thanks</div>
 <div>
 <div>
 <p><strong><font color="#ff00ff"><font color="#0000ff">Chandrajeet
 Padhy.</font></font></strong></p></div></div>
 <br></div><br>
     <hr size=1>Looking for a deal? <a href="http://us.rd.yahoo.com/evt=47094/
*http://farechase.yahoo.com/;_ylc
=X3oDMTFicDJoNDllBF9TAzk3NDA3NTg5BHBvcwMxMwRzZWMDZ3JvdXBzBHNsawNlbWFpbC1uY20-"
>Find great prices on flights and hotels</a> with Yahoo! FareChase.</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/

©2008 junlu.com - Jax Systems, LLC, U.S.A.