ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem with iText pdfwriter.getinstance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with iText pdfwriter.getinstance

    Hello,

    Im trying to use the itext pdfwriter.get instance but it comes back with nosuch method error. I was hoping someone could help me out.

    I think my signature is wrong but I cant seem to eyeball it.

    Message . . . . : Java exception received when calling Java method (C G D
    F).
    Cause . . . . . :
    Java exception "java.lang.NoSuchMethodError:
    com/itextpdf/text/pdf/PdfWriter.getInstance(Lcom/itextpdf/text/Document"
    when calling method "getInstance" with signature
    "(Lcom.itextpdf.text.Document;Ljava.io.FileOutputS treamV" in class
    "com.itextpdf.text.pdf.PdfWriter".


    My class assignment is below:

    Code:
    D PdfWriter       S               O   CLASS(*JAVA               
    D                                     :'com.itextpdf.text.pdf-  
    D                                     .PdfWriter')
    This is my method definition

    Code:
    D PdfWriterGetInstanse...                                                
    D                 PR                  EXTPROC(*JAVA                      
    D                                     :'com.itextpdf.text.pdf.PdfWriter' 
    D                                     :'getInstance')                    
    D pdfDocument                         like(iTextDocument)                
    D fileOutPutStream...                                                    
    D                                     like(FileOutputStream)
    And my useage


    Code:
    aString = new_String('/tmp/pdftest.pdf');       
    fos = new_FileOutputStream(aString);            
    pdfwtr = new_PdfWriter;                         
                                                    
    newdoc = new_ITextDocument;                     
    PdfWriterGetInstanse(pdfwtr: newdoc: fos);     *getting nosuchmethod here
    Thank You

  • #2
    Re: Problem with iText pdfwriter.getinstance

    double check the method (prototype),, specially return type
    Last edited by dhanuxp; May 5, 2013, 09:33 PM.

    Comment


    • #3
      Re: Problem with iText pdfwriter.getinstance

      YES,,,
      just quick look... it is static & returns PdfWriter!!



      Code:
         
           D pdfwrt          S               O   CLASS(*JAVA : 'com.itextpdf.text.p+
           D                                     df.PdfWriter' ) 
      
           D*_____________________________ 
           D PdfWriterGetInstanse...	
           D                 PR              O   CLASS(*JAVA : 'com.itextpdf.text.p+
           D                                     df.PdfWriter' )
           D                                     EXTPROC(*JAVA : 'com.itextpdf.text+
           D                                     .pdf.PdfWriter' : 'getInstance' )
           D                                     STATIC
           D pdfDocument...                         
           D                                  O   CLASS(*JAVA : 'com.itextpdf.text.D+
           D                                     ocument' )
           D fileOutPutStream...
           D                                  O   CLASS(*JAVA : 'java.io.OutputStrea+
           D                                     m' )   
        
            /free
                          pdfwrt   = PdfWriterGetInstanse( newdoc:fos);
            /end-free
      Last edited by dhanuxp; May 6, 2013, 01:09 AM.

      Comment


      • #4
        Re: Problem with iText pdfwriter.getinstance

        Im such a dummy. I didnt see that at all.

        Many Thanx

        Comment


        • #5
          Re: Problem with iText pdfwriter.getinstance

          Im still having the same issue. Ive defined the class as static but still getting nosuchmethod.

          Comment


          • #6
            Re: Problem with iText pdfwriter.getinstance

            Never mind I found it. I had as a signature the FileoutputStream class. Instead of the Output Stream class. Chnaged that and it worked ...

            You da man ...

            Comment

            Working...
            X