Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Problem with getTextFromPage Method

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

  • Problem with getTextFromPage Method

    I'm trying to use the getTextFromPage method on the PdfTextExtractor Class in iText-2.1.4.jar.

    Here are my prototypes:
    Code:
    D PdfTextExtractor...
    D                 S               O   CLASS(*JAVA
    D                                     :'com.lowagie.text.pdf-
    D                                     .parser.PdfTextExtractor')
    
    D new_PdfTextExtractor...
    D                 PR                  like(PdfTextExtractor)
    D                                     ExtProc(*JAVA
    D                                     :'com.lowagie.text.pdf-
    D                                     .parser.PdfTextExtractor'
    D                                     :*CONSTRUCTOR)
    D  inReader                           like(PdfReader)
    
    D PdfTextExtractor_getTextFromPage...
    D                 PR                  like(jString)
    D                                     EXTPROC(*JAVA
    D                                     :'com.lowagie.text.pdf-
    D                                     .parser.PdfTextExtractor'
    D                                     :'getTextFromPage')
    D  argPageNbr                         like(jint) value
    ...and here's my logic:
    Code:
    /free
       airDocument = AirPdf_newReader(%trim(#lcstmf));
       airPages = Pdfreader_getNumberOfPages(airDocument);
       airExtractor = new_PdfTextExtractor(airDocument);
       airPage = 1;
       dow airPage <= airPages;
         [COLOR="red"]airString = PdfTextExtractor_getTextFromPage(airPage);[/COLOR]
         airBytes = String_getBytes(airString);
         #lcpage = airBytes;
       airPage = airPage + 1;
       enddo;
       Pdfreader_close(airDocument);
       // Clean Up
       freeLocalRef(airDocument);
       freeLocalRef(airExtractor);
    /end-free
    When I try to compile, I'm getting:

    *RNF5406 30 1 The call passed fewer parameters than the prototype indicates
    are required.
    *RNF7535 30 1 The type and attributes of the parameter do not match those
    of the prototype.
    ...both pointing to the line in red above.

    The documentation for the class shows this:
    Code:
    getTextFromPage
    
    public String getTextFromPage(int page)
                           throws IOException
    
        Gets the text from a page.
    
        Parameters:
            page - the page number of the page 
        Returns:
            a String with the content as plain text (without PDF syntax) 
        Throws:
            IOException
    To me it looks like I have it defined correctly, so I can't figure out where these compile messages are coming from.

    Any thoughts?

  • #2
    Nevermind. After one change to my prototype /include file...I didn't recreate the service program SVAIRPDF so it was picking up the wrong prototype. I got it to compile, but now I'm getting a hard error that's making the JVM end. The code has changed to this:

    /free
    airDocument = AirPdf_newReader(%trim(#lcstmf));
    airPages = Pdfreader_getNumberOfPages(airDocument);
    airExtractor = new_PdfTextExtractor(airDocument);
    airPage = 1;
    dow airPage <= airPages;
    airString = PdfTextExtractor_getTextFromPage(airDocument:airPa ge)
    airBytes = String_getBytes(airString);
    #lcpage = airBytes;
    airPage = airPage + 1;
    enddo;
    Pdfreader_close(airDocument);
    // Clean Up
    freeLocalRef(airDocument);
    freeLocalRef(airExtractor);
    /end-free

    Comment


    • #3
      It's working now...but #lcpage only contains the first 256 bytes of the string being loaded up from the method pdfTextExtractor_getTextFromPage. I look at the prototype for String_getBytes and it supports strings up to 64k in length so why is it only returning the first 256 bytes?

      Comment


      • #4
        Nevermind...AGAIN. airBytes was defined as 256 for another function. I just created another variable called airBytes32k to hold the results. I should really look a little harder before jumping to the forum for answers :-)

        Comment


        • #5
          Sounds like you're getting it! Have fun!

          Comment

          Working...
          X