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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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.



----- Original Message ----
From: Clair W. Cabal <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, June 20, 2007 11:30:51 AM
Subject: [iText-questions] Dynamic content in document header



My task is this:  create a pdf report document of many pages where each page 
has a header with both fixed content and dynamic content (the value changes 
periodically throughout the report).  

 

I have been unable to accomplish this.  I have a class that builds the report 
and a class that builds the header which extends PdfPageEventHelper.  The 
PdfPageEventHelper class has access to the attributes that periodically change 
in the report class.  I initialize the variables that need to display in the 
onStartPage method, and display the header information in the onEndPage method. 
 Whatever the LAST variable values are for the report is what gets printed in 
the header of every page.  So, it looks like the PdfPageEventHelper methods do 
not execute until the entire document is complete – by which time I have lost 
the ability to capture the values I need.  Is there a way to do this?  

 

Clair W. Cabal

Nelson & Associates

 



  _____  

Park yourself in front of a world of choices in alternative vehicles.
Visit  
<http://us.rd.yahoo.com/evt=48246/*http://autos.yahoo.com/green_center/;_ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2VudGVy>
 the Yahoo! Auto Green Center.

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to