B4J Question Best PDF lib for my task

MarcRB

Active Member
Licensed User
Longtime User
Hello,

Is here a good example for creating a PDF in B4J with background, text, table and images?

Just like an invoice, containing text, (product)table, (product)images.
I see a lot of PDF libs, But what is the best solution for 2021?
PDFBox (without Acroform), jsPDF, PDFWriter, PDFjet, DynaPDF?

I think of two options:
Create a new pdffile, add pages, add content containing text, tables and images and import another PDF or fullpage image as backgroud (companylogo, header, footer and watermark)

or

Open a pre created, 'blank' pdf with company design (already containing companylogo, header, footer and watermark)
and edit that file by adding text, tables and images.

Can someone point me to an example?

Best regards,
Marc
 

jahswant

Well-Known Member
Licensed User
Longtime User
The answer is Yes. You need PDFJET.
 
Upvote 2

MarcRB

Active Member
Licensed User
Longtime User
I placed the jar in libraries folder and tested that PDFjet demo.
It doesn't work. Could it be outdated and no longer compatible?
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
I just used the pdfjet.jar file and the example, compiled and choose 'basic example' in the combobox.
I also tried different (j)pdfjet.jar files that I found on the net, but in all cases this in the result.
I know there are features that will only work in licenseced version.
I use jdk-11.0.1

Stack:
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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:233)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

java.lang.RuntimeException: java.lang.NoSuchMethodError: com.pdfjet.TextLine.setPosition(FF)V
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:233)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

Caused by: 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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)

    ... 9 more
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
This is the right version of the jar file, now i can run the PDFjet example.
This was so helpfull. Thank you.

(only the last link worked)
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…