NoSuchMethodError: com.cete.dynamicpdf.Font.getCourier

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v6)  /  NoSuchMethodError: com.cete.dynamicpdf.Font.getCourier

DynamicPDF Generator for Java (v6) Forum

Trying to upgrade to the latest version and converting some of our code to remove the deprecated methods, but in one of our subroutines we are getting this error. The code is as follows:

  String str = new String(textPage);
        TextArea textArea = new TextArea(str, 0, 0, 500, 700);
        textArea.setFont(Font.getCourier());
        textArea.setFontSize(10);
        do {
            Page page = new Page();
            page.getElements().add(textArea);
            document.getPages().add(page);
            textArea = textArea.getOverflowTextArea();
        } while (textArea != null);

It then throws this error.

If I change the code to:

  String str = new String(textPage);
        TextArea textArea = new TextArea(str, 0, 0, 500, 700);
        textArea.setFont(FontFamily.getCourier().getRegular());
        textArea.setFontSize(10);
        do {
            Page page = new Page();
            page.getElements().add(textArea);
            document.getPages().add(page);
            textArea = textArea.getOverflowTextArea();
        } while (textArea != null);

Then the code doesn't fail. Looks like a unit test should be written :)
Posted by a ceTe Software moderator
Hello,

In version 6.0 both Font.getCourier()and FontFamily.getCourier().getRegular() are available in the API.

You can refer to the list of deprecated classes here.

Thanks,
ceTe Software Support Team.
Yes I agree that both methods exist and are not deprecated. But if you use the Font.getCourier() method, the application will throw an exception at runtime.

Sorry to confuse the topic mentioning deprecated methods. I was just stating that we are upgrading to the new version and were re-coding and testing with the new version. During testing, we ran across this scenario.

If you write a simple test app similar to my first example, you will get a runtime exception with the DynamicPDF.jar version 6.0.1 that I downloaded off your website this morning.
Posted by a ceTe Software moderator
Hello,

We ran the below test code against DynamicPDF Java v6.0.1 build 18767 that is available for download on the website and we were able to generate the PDF document without any error. NoSuchMethodError during run-time might be caused due to some reference issue in your project. Please check to make sure that the correct version of jar file is referenced in your project and that your application jar file is calling the correct version of DynamicPDF jar file. 

          com.cete.dynamicpdf.Document document = new com.cete.dynamicpdf.Document();         
          com.cete.dynamicpdf.Page page = new com.cete.dynamicpdf.Page();
          document.getPages().add(page);          
          com.cete.dynamicpdf.pageelements.TextArea textArea = new com.cete.dynamicpdf.pageelements.TextArea("test", 0, 0, 500, 700);
          textArea.setFont(com.cete.dynamicpdf.Font.getCourier());         
          page.getElements().add(textArea);       
          document.draw("c:/test.pdf");

Thanks,
ceTe Software Support Team.
i want add color on perticular text in pdf, so please help me,
using this textarea

TextArea textAreaA2 = new TextArea(fromPlace, 100, 70, 800, 400,com.cete.dynamicpdf.Font.getHelveticaBold(), 10,------- ) {
Posted by a ceTe Software moderator
Hello,

You can set the color for the TextArea text using the setColor method of the TextArea class. Below is the sample code for it.

textArea.setTextColor(RgbColor.getBlue());

If you are trying to set color to the part of the text within the TextArea then it is not supported by TextArea class and you will need to use the FormattedTextArea page element to do this and use the HTML tags to build the text and set the desired color to the particular text. Please refer documentation on FormattedTextArea class at: http://www.dynamicpdf.com/Support/Java_Help_Documentation_11_01/api-examples/FormattedTextArea.html#Example1 .


Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:24 PM.