Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Problem using jPDFText.jar

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

  • Problem using jPDFText.jar

    I'm trying to use jPDFText.jar from Qoppa (http://www.qoppa.com/pdftext/jptindex.html).

    I've used java libraries before, but I'm having a problem with this one.

    Relevant service program lines:
    Code:
    D PdfText         S               O   CLASS(*JAVA
    D                                     :'com.qoppa.pdfText.PDFText')
    D PdfPassword     S               O   CLASS(*JAVA
    D                                     :'com.qoppa.pdf.PDFPassword')
    ...
    D new_PdfText...
    D                 PR                  like(PdfText)
    D                                     ExtProc(*JAVA
    D                                     :'com.qoppa.pdfText.PDFText'
    D                                     :*CONSTRUCTOR)
    D  inFileName                         like(jString)
    D  inPDFPassword                      like(PdfPassword)
    D new_PdfPassword...
    D                 PR                  like(PdfPassword)
    D                                     ExtProc(*JAVA
    D                                     :'com.qoppa.pdf.PDFPassword'
    D                                     :*CONSTRUCTOR)
    D  inString                           like(jString)
    Program usage:
    Code:
    #lcstmf = tgdpath;
    #lcstmfj = new_String(%trim(#lcstmf));
    #lcpwdj = new_String(#lcblank);
    #lcpdfpwd = new_PdfPassword(#lcpwdj);
    #lcdocument = new_PdfText(#lcstmfj:#lcpdfpwd);
    I get this error:
    Code:
    Message . . . . :   Java exception received when calling Java method.
    Cause . . . . . :   RPG procedure SOR005 in program WORKLIBR/SOR005CL receiv
      Java exception "java.lang.NoSuchMethodError: < init >" when calling method
      "< init >" with signature "(Ljava.lang.String;Lcom.qoppa.pdf.PDFPassword;)V"
      in class "com.qoppa.pdfText.PDFText".
    ...but when I run STRQSH CMD('javap -s com.qoppa.pdfText.PDFText'), I can see this signature (along with others):

    Code:
    public com.qoppa.pdfText.PDFText(java.lang.String, com.qoppa.pdf.IPassword)
     throws com.qoppa.pdf.PDFException;
      Signature: (Ljava/lang/String;Lcom/qoppa/pdf/IPassword;)V
    To me, my signature matches the one seen in javap output. Why is the error being thrown?
    Last edited by bsnuggs76; 03-15-2011, 10:50 AM.

  • #2
    jPDFText Polymorphism on Prototype

    I don't use jPDFText, but I believe this will fix your problem.

    Code:
    D PdfText         S               O   CLASS(*JAVA
    D                                     :'com.qoppa.pdfText.PDFText')
    D PdfPassword     S               O   CLASS(*JAVA
    D                                     :'com.qoppa.pdf.PDFPassword')
    D IPassword       S               O   CLASS(*JAVA
    D                                     :'com.qoppa.pdf.IPassword')
    ...
    D new_PdfText...
    D                 PR                  like(PdfText)
    D                                     ExtProc(*JAVA
    D                                     :'com.qoppa.pdfText.PDFText'
    D                                     :*CONSTRUCTOR)
    D  inFileName                         like(jString)
    D  inPDFPassword                      like(IPassword)
    D new_PdfPassword...
    D                 PR                  like(PdfPassword)
    D                                     ExtProc(*JAVA
    D                                     :'com.qoppa.pdf.PDFPassword'
    D                                     :*CONSTRUCTOR)
    D  inString                           like(jString)
    I believe you have my book Advanced Integrated RPG. You could find more information on this on pages 171 and 172 that discusses polymorphism and it's usage with prototypes.

    In summary, PDFPassword implements the IPassword interface, but the signature is different for each object when trying to find the matching signature on the prototype.

    As I said, I don't have this package installed, so there may be a typo because I typed it off the cuff. But, I think you get the idea.

    Enjoy,
    Tom

    Comment


    • #3
      Thanks Tom. That was the problem.

      I'm forced to use this other library because of the problems I'm having with iText (http://www.mcpressonline.com/forum/s...-quot-error-in).

      Comment


      • #4
        I would love to use iText instead (so I wouldn't have to force the usage of the 5.0 version of JVM...and PAY for the jar file). Any idea's on what would cause the problem I was originally having?
        http://www.mcpressonline.com/forum/s...-quot-error-in

        Here is the PDF I was trying to read:
        http://www.uspto.gov/web/trademarks/...0110118_OG.pdf

        Comment


        • #5
          Great! I'm glad that was the fix for you.

          Sorry I don't have any more information on your original problem. I've played with the PDF text extractor in iText, but I never used the text extractor under full production load so I don't have any additional information on the limitations that you've run into.

          I plan on updating to the latest version soon, and I'll see if I could run into your problem with a possible solution while I'm at it. But I'm sure you'll be happily using your jPDFText version by then

          Glad I could help, Good luck with your jPDFText project!
          Tom

          Comment


          • #6
            Downloaded. I was going to ask you for a sample, but I wasn't sure if it was classified or not. This is an awesome example! Lots of pages and tons of text for validation. I don't know when I'll get the chance to try it out, but I'll let you know if I come up with anything.

            I don't know if it makes a difference, but have you tried the latest version of iText when you were doing your development?

            Comment


            • #7
              No. The latest version requires Java 5.0 and I was having some problems with that JVM version on my AS400.

              I hit another snag with jPDFText, though.

              We ended up buying it and they use a setKey method to unlock production use of the library. I can't seem to get that method to work correctly. I'm sure it's something minor.

              Here's the javadoc:
              http://www.qoppa.com/pdftext/guide/j...va.lang.String)

              Here's the signature from "javap -s com.qoppa.pdfText.PDFText":
              Code:
              public static boolean setKey(java.lang.String);
                Signature: (Ljava/lang/String;)Z
              Here's my prototype:
              Code:
              D PdfText_SetKey...
              D                 PR              n
              D                                     EXTPROC(*JAVA
              D                                     :'com.qoppa.pdfText.PDFText'
              D                                     :'setKey')
              D                                     static
              D  inString                           like(jString)
              Here's my app code (the setkey only needs to occur once in the program):
              Code:
              if not #lcsetkey;
                #lclickey = new_String(%trim(jpdflickey));
                eval #lcbool = PdfText_SetKey(#lcdocument:#lclickey);
                eval #lcsetkey = *on;
              endif;
              I get this error:
              Code:
              Message . . . . :   Java exception received when calling Java method.
              Cause . . . . . :   RPG procedure SOR005 in program WORKLIBR/SOR005CL received
                Java exception "java.lang.NoSuchMethodError: setKey" when calling method
                "setKey" with signature "(Ljava.lang.String;)Z" in class
                "com.qoppa.pdfText.PDFText".
              I have a feeling the problem is in my prototype. If the return type is boolean in a java function, how would I note that in the prototype?

              Comment


              • #8
                I changed the prototype to this:
                Code:
                D PdfText_setKey...
                D                 PR                  like(jboolean)
                D                                     EXTPROC(*JAVA
                D                                     :'com.qoppa.pdfText.PDFText'
                D                                     :'setKey')
                D                                     static
                D  inString                           like(jString)
                ...and changed the app code to this (since it was a static method it needed no object reference):
                Code:
                if not #lcsetkey;
                  #lclickey = new_String(%trim(jpdflickey));
                  eval #lcjbool = PdfText_SetKey(#lclickey);
                  eval #lcsetkey = *on;
                endif;
                Now I get a compile error:

                *RNF3967 30 1 The datatype is not allowed for the return value of a method.

                ...even through the datatype is the is the correct one.
                Last edited by bsnuggs76; 03-17-2011, 08:17 AM.

                Comment


                • #9
                  Changed the prototype back to the original after finding this blurb on a google search:

                  The returned value is specified as N, which maps to the Java boolean data type

                  That...along with the change of not passing it the object reference got it to compile and run without a runtime error.

                  It still fails on any page > 10...which is a limitation of the trial version...which means the setkey didn't actually work.

                  I'll call Qoppa at this point.

                  Comment

                  Working...
                  X