B4J Library jPDFjet

jPDFjet is a PDF document authoring library for B4J

jPDFjet wraps the PDFjet for Java library from pdfjet.com.
Here are some of it's features:

Drawing support for:
  • Points
  • Lines
  • Boxes
  • Circles
  • Bezier Curves
  • Polygons
  • Stars
  • Complex paths and shapes

Text
  • Unicode support
  • Text kerning when using the Helvetica and Times-Roman families of core fonts
  • Embedding hyperlinks
  • Support for embedding OpenType and TrueType fonts
  • Support for the fonts included with Reader 7.0 and Reader 8.0 installations

Embedding of the following types of images:
  • PNG
  • JPEG
  • BMP

High level components:
  • Simple to use Table class with flexible reporting capabilities
  • Flexible Chart component with support for scatter plots and lines
  • TextColumn component with text kerning and justification support
  • Support for Code 39 and Code 128 barcodes
  • Support for PDF417 and QR code 2D barcodes

PDFjet for Java is available under Open Source, free evaluation and paid for licenses.
jPDFjet can be used with all three licenses.
The Open Source Edition is feature limited.
jPDFjet wraps all available features of the paid for license version - any features that are not available in the Open Source Edition will show in the B4J IDE but not be available for use.
Trying to use a feature that is not available is like to raise a ClassNotFound exception.


In order to use jPDFjet you will need to:
When downloading either version you will agree to and accept the license terms and conditions that apply to the version you download.

EDIT: Please read post #2 in this thread to find out about the available versions of PDFjet for Java.

Your PDFjet for Java download will contain the java library file PDFjet.jar.
Copy PDFjet.jar to your B4J additional libraries folder.

Now download the attached jPDFjet library files and copy these to your B4J additional library folder.
Your B4J additional libraries folder should now contain: jPDFjet.jar, jPDFjet.xml and PDFjet.jar.
jPDFjet.html is for reference only - you don't need to copy this file to your additional libraries folder.

If you upgrade from the Open Source Edition or from the free version to the paid for version you just need to overwrite the Open Source Edition or free version of PDFjet.jar with your paid for version of PDFjet.jar.
One thing i have not done is to add a lot of the javadoc reference to the B4J library.
Many methods are self-explanatory, some are obscure and some lack any javadoc reference.
In your download from pdfjet.com there is a folder docs/java which contains the PDFjet for Java javadoc reference.
Open docs/java/index.html in your browser to see all the available reference/documentation.

There are some java examples of usage of PDFjet both online and in the download from pdfjet.com.
I have converted some of these java examples to B4J and the attached B4J demo project contains those converted examples.

Note that i have also created a B4A version of this library and shall upload the B4A version shortly.
Both B4A and B4J versions share the same syntax.

Library files and demo project attached.

Martin.
 

Attachments

  • jPDFjet-demo-project.zip
    67 KB · Views: 3,341
  • jPDFjet-library_files-v1.10.zip
    78.9 KB · Views: 4,099
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
I think you should start a new thread for this. It's not related to the library PDFJet.
I think the problem comes from your code, you are actually putting an image for each row at column 3 in your code.
 

Phayao

Active Member
Licensed User
Longtime User
Sorry, I have to disagree - when I do not use PDFTable.WrapAroundCellText, the table with the pictures is OK. But of course then then text is jumbled up, like this:

pdftable2.jpg

Therefore it's clearly a problem with the library in my opinion.
Or in other words: It seems not possible to have an image in a table row when using PDFTable.WrapAroundCellText - can somebody confirm or disproof this ?

Thank you,
Chris
 

alwaysbusy

Expert
Licensed User
Longtime User
I used the exact code as in the real java example and then no blank page is printed at the end:

B4X:
Do While True
        PDFTable.DrawOn(PDFPage)
        If Not(PDFTable.HasMoreData) Then
            PDFTable.ResetRenderedPageCount
            Exit
        End If
        PDFPage.Initialize(PDFjetPDF1, PDFjetConstants1.PageSize.A4_PORTRAIT)
Loop
 
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
Trying to print a Barcode, I get an error:

B4X:
print clicked
Error occurred on line: 97 (ABMPrint)
java.lang.NoClassDefFoundError: com/pdfjet/BarCode
    at uk.co.martinpearman.b4j.pdfjet.BarCodeWrapper.Initialize(BarCodeWrapper.java:25)
    at abmaterial.ab.com.abmprint._printtopdf(abmprint.java:304)
    at abmaterial.ab.com.comptreetablepage._btnprint_clicked(comptreetablepage.java:80)
    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:607)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:462)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:417)
    at abmaterial.ab.com.comptreetablepage._page_parseevent(comptreetablepage.java:1109)
    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:607)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:126)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:300)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at abmaterial.ab.com.main.main(main.java:29)
Caused by: java.lang.ClassNotFoundException: com.pdfjet.BarCode
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 46 more

Printing tables and so on seems to work great!



The code I use:

B4X:
Dim code As PDFjetBarCodecode.Initialize(code.CODE39, "123456789")
code.setPosition(0.0, 0.0)
code.setModuleLength(0.75)
code.setFont(PDFFont)
code.drawOn(PDFPage)
 

DonManfred

Expert
Licensed User
Longtime User
Trying to print a Barcode, I get an error

See Post #1

PDFjet for Java is available under Open Source, free evaluation and paid for licenses.
jPDFjet can be used with all three licenses.
The Open Source Edition is feature limited.
jPDFjet wraps all available features of the paid for license version - any features that are not available in the Open Source Edition will show in the B4J IDE but not be available for use.
Trying to use a feature that is not available is like to raise a ClassNotFound exception.
 

alwaysbusy

Expert
Licensed User
Longtime User
Can anyone who has a license of PDFJet try to print a 1D barcode? It's the only reason I would need to buy it. If I try it with the evaluation version (should do everything the licensed one does, no?) it seems to have found the BarCode class, but then the method drawOn() does not exist:

B4X:
print clicked
Error occurred on line: 101 (ABMPrint)
java.lang.NoSuchMethodError: com.pdfjet.BarCode.drawOn(Lcom/pdfjet/Page;)V
    at uk.co.martinpearman.b4j.pdfjet.BarCodeWrapper.DrawOn(BarCodeWrapper.java:21)
    at abmaterial.ab.com.abmprint._printtopdf(abmprint.java:316)
    at abmaterial.ab.com.comptreetablepage._btnprint_clicked(comptreetablepage.java:80)
    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:607)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:462)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:417)
    at abmaterial.ab.com.comptreetablepage._page_parseevent(comptreetablepage.java:1109)
    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:607)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:126)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:300)
    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)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at abmaterial.ab.com.main.main(main.java:29)
 

warwound

Expert
Licensed User
Longtime User
Which version of PDFjet are you using?
The last time i had access to the paid for version of PDFjet it was version 5.07 and the native PDFjet BarCode class certainly had a drawOn(Page page) method.
I've attached the version 5.07 javadoc for you info.
 

Attachments

  • PDFjet-ForJava-v5.07-docs.zip
    155.9 KB · Views: 499

warwound

Expert
Licensed User
Longtime User
Ah that explains it.
I doubt you'll find a download link for an old version of the demo.
I could let you have the b4j library source if you want to modify it to work with your version of the demo?
Or perhaps another forum member has demo version 5.07 and could let you have a copy...
 

khaleel

Member
Licensed User
Longtime User
Hello, I tried this demo and its okay.
but when chnaging some text in the "world-communications.txt" file to some Arabic text,
this text did not show when previewing the .pdf file using adobe

Any idea about why is this and what should I do to show Arabic text ?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hello!

I downloaded the PDF Evaluation version from PDFJET webpage and every Demo failed, after i downloaded the compiled version that Warwound all of them worked, it seems that the wrapper is now outdated. Just a comment.
 
Top