B4J Library jPDFjet

Discussion in 'B4J Libraries & Classes' started by warwound, Feb 15, 2014.

  1. Phayao

    Phayao Member Licensed User

    Hello, another stupid question .....

    I run the jpdfdemo from the first post, using the libraries from this post also.
    After choosing "Table" i get the following error:

    Program started.
    lastdir: D:\www\B4J\PDFJET~1\Objects
    file: Table.pdf
    java.lang.RuntimeException: java.lang.NoSuchMethodError: com.pdfjet.Font.setSize(F)V
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA$2.run(BA.java:165)
    at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.NoSuchMethodError: com.pdfjet.Font.setSize(F)V
    at uk.co.martinpearman.b4j.pdfjet.FontWrapper.SetSize(FontWrapper.java:98)
    at uk.co.martinpearman.b4j.pdfjetexample.main._createpdftable(main.java:1163)
    at uk.co.martinpearman.b4j.pdfjetexample.main._createbutton_action(main.java:229)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:606)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:225)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 9 more

    This error appeared suddenly (?) also in my own program using the jPDF library ...
    Maybe anyone had the same problem and can give some advice - much appreciated,

    Thank you, Chris
     
  2. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    It could be 2 issues.

    Warwound stated that some methods are not available in the open source jar.

    The other one is that you updated your pdfjet jar to the most updated version from their webpage and this wrapper is outdated.

    In the second post of this thread you will find a compiled version of the open source PDFjet.jar. Replace it for the one you have in your folder, if that does not solve the issue avoid using the font.setsize method.
     
    Phayao likes this.
  3. jahswani

    jahswani Active Member Licensed User

    Is there a workaround for this issue ?
    Me too i'm getting this...
     
  4. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    This is not a problem for the wrapper, but for the API, the PDFJet team are very active with their product, i contacted them 3 weeks ago and they answered me within hours, may be you can reach them for a solution.
     
    jahswani likes this.
  5. Don Oso

    Don Oso Member Licensed User

    Hi , all links now are broken , i loose my HD and need the PDFjet.jar with compiled method not included in the original open source code.

    Any one can upload those files ?

    Thanks.
     
  6. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    I cannot remember if i compiled this version my self, you should try it.
     

    Attached Files:

    mshafiee110 and inakigarm like this.
  7. Don Oso

    Don Oso Member Licensed User

    Gracias Enrique ! voy a probar / Thanks Enrique im cheking
     
    Enrique Gonzalez R likes this.
  8. Don Oso

    Don Oso Member Licensed User

    mmmm same problem im getting same error with your .jar

    Waiting for debugger to connect...
    Program started.
    java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
    at uk.co.martinpearman.b4j.pdfjet.TextLineWrapper.SetPosition(TextLineWrapper.java:106)
    at uk.co.martinpearman.b4j.pdfjetexample.main._createpdfbasicexample(main.java:272)
    at uk.co.martinpearman.b4j.pdfjetexample.main._createbutton_action(main.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA$1.run(BA.java:215)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)
    java.lang.RuntimeException: java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA$1.run(BA.java:215)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
     
  9. alwaysbusy

    alwaysbusy Expert Licensed User

    @Don Oso I still have jPDFJet 1.10 around somewhere. PM me if you need it.
     
  10. ajk

    ajk Active Member Licensed User

    It works correctly as below with European code set
    Code:
    Dim InputStream1 As InputStream
        InputStream1 = 
    File.OpenInput(File.DirAssets,"droid-serif.regular.ttf")
        PDFFont1.Initialize3 (PDFjetPDF1, InputStream1)
     
  11. mshafiee110

    mshafiee110 Member Licensed User

    Hi dear @warwound, can you update this great lib ?tnx
     
  12. neuronio

    neuronio New Member Licensed User

    I have the same error.
     
  13. Don Oso

    Don Oso Member Licensed User

    Use this file, copy the jar file to your b4j library directory.

    Regards
     

    Attached Files:

  14. neuronio

    neuronio New Member Licensed User

    Thx @Don Oso!!! :)
    Unfortunately it did not work ...

    I tried to compile the PDFjet (Open) and create the library with the SLC, but it presented error in both.
    Also tried running everything with a clean VM and with JDK-8u151, made the same error.

    Code:
    Waiting for debugger to connect...
    Program started.
    java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
        at uk.co.martinpearman.b4j.pdfjet.TextLineWrapper.SetPosition(TextLineWrapper.java:
    106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.shell.Shell.runVoidMethod(
    Shell.java:657)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:234)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:159)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    90)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    93)
        at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:
    61)
        at uk.co.martinpearman.b4j.pdfjetexample.main._createpdfbasicexample(main.java:
    242)
        at uk.co.martinpearman.b4j.pdfjetexample.main._createbutton_action(main.java:
    196)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:613)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:231)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:159)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    90)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    93)
        at anywheresoftware.b4a.BA$
    1.run(BA.java:215)
        at com.sun.javafx.application.PlatformImpl.lambda$
    null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$
    173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$
    Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$
    null$147(WinApplication.java:177)
        at java.lang.Thread.run(
    Thread.java:748)
    Error occurred on line: 
    130
    java.lang.RuntimeException: java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    119)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    93)
        at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:
    61)
        at uk.co.martinpearman.b4j.pdfjetexample.main._createpdfbasicexample(main.java:
    242)
        at uk.co.martinpearman.b4j.pdfjetexample.main._createbutton_action(main.java:
    196)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:613)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:231)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:159)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    90)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    93)
        at anywheresoftware.b4a.BA$
    1.run(BA.java:215)
        at com.sun.javafx.application.PlatformImpl.lambda$
    null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$
    173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$
    Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$
    null$147(WinApplication.java:177)
        at java.lang.Thread.run(
    Thread.java:748)
    Caused by: java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
        at uk.co.martinpearman.b4j.pdfjet.TextLineWrapper.SetPosition(TextLineWrapper.java:
    106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.shell.Shell.runVoidMethod(
    Shell.java:657)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:234)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:159)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.lang.reflect.Method.invoke(Method.java:
    498)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    90)
        ... 
    25 more
    An error occurred: 
    (Line: 
    131) PDFTextLine.SetText("This is the PDFjetTextLine o
    java.lang.Exception: array not expected...

     
  15. DonManfred

    DonManfred Expert Licensed User

    Are you sure you have a FULL Version (paid license) of pdfjet?

    So it sounds like this is maybe only available in the paid version of pdfjet....
     
    neuronio likes this.
  16. Cassie

    Cassie Member Licensed User

    Hi Guys,

    Anyone could, I have recently a working PDFjet.jar but I have accidentally overwrite it and gives me an error java.lang.NoSuchMethodError: com.pdfjet.Font.setSize(F)V
    blablabla...

    Thanks in advance.
     
  17. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    The problem between the pdfJet and this library is that at one point in time the creators decided that to use float instead of double, that is why there are to many errors. not because it is or it is not free or paid.

    so because even paying will not solve the issue, the best way to overcome the error is brewing your own library, it is not as hard as you think. i remember doing it with inline java. something like this;


    Code:
    Sub Class_Globals
        
    Private PDFobject As Object
        
    Private Output As OutputStream

    End Sub

    'Initializes the object. You can add parameters to this method if needed.
    Public Sub Initialize(path As String, name As String)
        Output = 
    File.OpenOutput(path,name,False)
        PDFobject = init(Output)   

    End Sub

    private Sub init(fos As OutputStreamAs Object
        
    Return inline.RunMethod("init",Array(fos))
    End Sub

    Public Sub Flush 
        inline.RunMethod(
    "Flush",Array(PDFobject))
        Output.Close
    End Sub

    public Sub Flush2
        Output.Close
    End Sub

    public Sub addPage(pageOB As Page)
            inline.RunMethod(
    "addPage",Array(PDFobject,pageOB.PageOb))
    End Sub

    public Sub PDFOb As Object
        
    Return PDFobject
    End Sub

    private Sub inline As JavaObject
    Return Me
    End Sub

    #if Java

    import java.io.*;
    import java.util.*;

    import com.pdfjet.*;

        static public PDF init(OutputStream fos) throws Exception { 
            PDF pdfob = new PDF(fos);
            return pdfob;
        }
       
        static public void Flush(PDF pdf) throws Exception { 
            pdf.flush();
        }
       
        static public void addPage(PDF pdf, Page page) throws Exception  { 
            pdf.addPage(page);
        }
       
    #end if
    there are other classes to do it: page and fonts mainly. Page has all the methods to write to the pdf canvas such as string, lines and images.

    hope this helps anyone.

    i am by no means java expert, not even a newbie, i have never been able to compile a eclipse project and even then brewing my own library was not difficult.
     
    jimmyF likes this.
  18. Cassie

    Cassie Member Licensed User

    Hi Enrique,

    Thanks for the response. Can you explain how does it works.

    Thanks in advance.
     
  19. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    Yes! it is not difficult!

    with the code above you can create an instance of the pdf object that holds the pages and the fonts objects.

    another example is to create the font object

    Code:
    Dim FontObject as object = inline.RunMethod("init",Array(PDFOB,Name.ToUpperCase,size)) 'Here you pass the object created in the class i above

    private Sub inline As JavaObject
    Return Me
    End Sub

    #if Java
    import java.io.*;
    import java.util.*;
    import com.pdfjet.*;

        static public Font init(PDF pdf,String fontName, double fontSize) throws Exception { 
            Font font = new Font(pdf,CoreFont.valueOf(fontName));
            font.setSize(fontSize);
            return font;
        }

    #end if
    The trick is to read the javadocs, you can find this javadocs inside the downloaded zip in their webpage
    http://pdfjet.com/os/download.html

    the one i created in the example above is the first constructor.

    i think you can oversimplify everything by calling javaobject instead of inline java, i was young and naive 2 years ago when i worked with it (since then the warwound library gave problems)
    upload_2018-1-20_13-6-13.png
     
  20. Omar Moreno

    Omar Moreno Member Licensed User


    Excuse my English (Translated with Google).

    Greetings Enrique.

    I have tested with version 1.10 of JPdfJet, but it does not work to generate bar codes.

    You could upload a simple example in ZIP to see the operation of this library, since the IDE gives me an error in this line "public Sub addPage (pageOB As Page)".

    I have used the PDFJet library creating a Java file which I then convert with the Simple Library Compiler utility, something similar to a Wrapper and it works, but since I do not have much experience in Java it is difficult for me to create a wrapper to generate any PDF document and not one for each PDF.

    Thanks for the help you can give me.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice