B4J Library jPDFjet

Phayao

Active Member
Licensed User
Longtime 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
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime 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.
 

jahswant

Well-Known Member
Licensed User
Longtime User
@alienhunter

When a PDF table spans more than one page the library seems to not handle table header rows properly.
Multi-line table headers seem to cause the library to fail to properly count the number of pages required to display a table.
Is there a workaround for this issue ?
Me too i'm getting this...
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Is there a workaround for this issue ?
Me too i'm getting this...

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.
 

Don Oso

Active Member
Licensed User
Longtime User
I cannot remember if i compiled this version my self, you should try it.
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)
 

ajk

Active Member
Licensed User
Longtime User
It works correctly as below with European code set
B4X:
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets,"droid-serif.regular.ttf")
    PDFFont1.Initialize3 (PDFjetPDF1, InputStream1)
 

mshafiee110

Active Member
Licensed User
Longtime User
Hi dear @warwound, can you update this great lib ?tnx
 

neuronio

Member
Licensed User
Longtime User

I have the same error.
 

neuronio

Member
Licensed User
Longtime 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.

B4X:
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...


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

Regards
 

DonManfred

Expert
Licensed User
Longtime User
Program started.
java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)

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....
 

Cassie

Member
Licensed User
Longtime 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.
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime 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;


B4X:
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 OutputStream) As 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.
 

Cassie

Member
Licensed User
Longtime User

Hi Enrique,

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

Thanks in advance.
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime 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

B4X:
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)
 

Omar Moreno

Member
Licensed User
Longtime 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.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…