Update content of TextArea

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v6)  /  Re: Update content of TextArea

DynamicPDF Generator for Java (v6) Forum

 Jul 28 2011 3:02 PM
After building a complete tree with Document,Page,PageElements etc I want to update one of my TextAreas using setText("some new text").
But when I do, and then save the pdf, the saved pdf is broken and cant be opened or displayed.
Am I missing something. The exact same thing works great when I'm using a Label instead.

The problem appears if I use setText() on a TextArea after it has been added to a Page object.
How Can I update the content of the TextArea after it has been added to the page?

Thanks,

Petrus
 Jul 29 2011 5:28 AM
Posted by a ceTe Software moderator
Hello Petrus,

We did some testing on our end using the version 6 DynamicPDF Generator for Java product jar file and we are able to set the text to the TextArea page element after adding it to Page object. Below is the sample code which we have used for our testing.

         Document document = new Document();
         Page page = new Page();
         document.getPages().add(page);
         String text = "HelloWorld.";
         Label label=new Label(text,10,200,200,200);
         TextArea textArea = new TextArea(text, 10, 10, 200, 200);
         page.getElements().add( label );
         page.getElements().add( textArea );
         textArea.setText("New Text");
         document.draw("C:/MyDocument.pdf" );

Please make sure that you are using latest DynamicPDF for Java product jar file in your application and this should work for you. You can download the latest jar file by logging into our CustomerArea: http://www.DynamicPDF.com/CustomerArea using your product serial number. Remove reference for the old jar file and reference the latest jar file in your application.

If you are evaluating the product then you can download the latest jar file from our website at: http://www.DynamicPDF.com/Products/DynamicPDFforJava/Download.csp.

If you continue getting the similar behavior even after using the latest jar file then please send over the sample code to our support team at: support@cete.com so that they can look into it further.

Thanks,
ceTe Software Support Team.
 Jul 29 2011 6:15 AM
Thanks for you quick reply!
Downloading the latest version solved the broken pdf-problem.
But the output is still not what is expected.
I've tracked down the problem to textArea.getRequiredHeight, or setHeight.

Here's a simple example that creates strange output.


         Document document = new Document();
         Page page = new Page();
         document.getPages().add(page);

         String text = "HelloWorld.";
         TextArea textArea = new TextArea(text, 10, 10, 200, 200);

        System.out.println("Height before: " + textArea.getHeight());
         textArea.setHeight(textArea.getRequiredHeight());        //this line causes problems. When used, the pdf-output is not what I expected.
        System.out.println("Height after: " + textArea.getHeight());

         page.getElements().add( textArea );

         textArea.setText("First line is longer than before\nWe also added a second line");

        System.out.println("Height finaly: " + textArea.getHeight());

         document.draw("MyDocument.pdf" );


Only "First line" is displayed in the pdf, nothing more.

BR,

Petrus
 Jul 29 2011 10:18 AM
Posted by a ceTe Software moderator
Hello Petrus,

We have released the latest build for the version 6 DynamicPDF for Java which address the issue which you reported. Please login to our CustomerArea: support@cete.com using your product serial number and download the latest jar file. Remove reference for the old jar file and reference the latest in your application.

You can download the evaluation edition of version 6 DynamicPDF product from our website at: http://www.DynamicPDF.com/Products/DynamicPDFforJava/Download.csp .
 
Thanks,
ceTe software Support Team.
 Jul 29 2011 11:13 AM
Works like a charm!

This is how a support forum is supposed to work! :)

Thanks!

Petrus
 Sep 03 2011 4:19 PM
cool forum

All times are US Eastern Standard time. The time now is 8:49 PM.