  | 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
|
|
|
  | | | JTable to PDF without any pagination | JTable to PDF without any pagination 2007-07-25 - By chandrajeet padhy
Back 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> </div> <div><font face="Courier New" size="2"><span class="001041217-25072007">1) You 're not actually drawing anything. </span></font></div> <div><font face="Courier New" size="2"><span class="001041217-25072007"></span> </font> </div> <div><font face="Courier New" size="2"><span class="001041217-25072007">Try a different G2D to test your output. 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> </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> </div> <div><font face="Courier New" size="2"><span class="001041217-25072007">White one white, that sort of thing. Probably not the issue.</span></font></div> <div><font face="Courier New" size="2"><span class="001041217-25072007"></span> </font> </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> </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.  ; 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> </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"> Senior Software Engineer</font> <br><font face="Arial" size="2"> Cardiff.com</font></p> <p><font face="Arial" size="2">#include <disclaimer></font> <br><font face="Arial" size="2">typedef std::Disclaimer<Cardiff> 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> Document document = new Document();<br> table.setVisible(true);<br> try { <br> // step 2: creation of the writer<br> PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE_NAME));<br> <br> // step 3: we open the document<br>   ; document.open();<br> <br> // step 4: we grab the ContentByte and do some stuff with it<br> <br> // we create a template and a Graphics2D object that corresponds with it<br> int w = table.getWidth();<br> int h = table.getHeight();<br> PdfContentByte cb = writer.getDirectContent();<br>   ; PdfTemplate tp = cb.createTemplate(w, h);<br> Graphics2D g2 = tp.createGraphics(w, h);<br> tp.setWidth(w);<br> tp.setHeight(h);<br> table.paint(g2);<br> g2.dispose();<br> cb.addTemplate(tp, 50, 400); <br> }<br> catch(DocumentException de) {<br> System.err.println(de.getMessage());<br> }<br> catch(IOException ioe) {<br> System.err.println(ioe.getMessage());<br> } <br> // step 5: we close the document<br> document.close();<br><br>But this prints absolutely nothing .<br> <div> 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/
|
|
 |