B4A Library PDFjetB4A

PDFjetB4A is a PDF document authoring library for B4A

PDFjetB4A 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 both free evaluation and paid for licenses.
PDFjetB4A can be used with both the free evaluation and paid for licenses.
The free license version used to be feature limited, it looks as though the latest free license version contains all the features of the paid for license but i have not checked that.
PDFjetB4A wraps all available features of the paid for license version - if any of those features are not available in the free license version then the features will show in the B4A 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 PDFjetB4A 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 to find out about all available versions of PDFjet for Java.

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

Now download the attached PDFjetB4A library files and copy these to your B4A additional library folder.
Your B4A additional libraries folder should now contain: PDFjetB4A.jar, PDFjetB4A.xml and PDFjet.jar.
PDFjetB4A.html is for reference only - you don't need to copy this file to your additional libraries folder.
If you upgrade from the free version to the paid for version you just need to overwrite the 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 B4A 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.

I have also created a B4J version of this library, see the jPDFjet thread.
Both B4A and B4J versions share the same syntax.

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 a B4J project and this B4J project is available in the jPDFjet thread.
(I've not had time to create a B4A demo project).

Library files attached.

Martin.
 

Attachments

  • PDFjetB4A-library-files-v1.10.zip
    78.8 KB · Views: 1,653
Last edited:

hibrid0

Active Member
Licensed User
Longtime User
Any example to create table to make a report?
I'm using the other pdf library and I'm tired with the tables.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Trying to use PDFjetTextColumn

B4X:
  Dim Box              As PDFjetBox
  Dim TextColumn  As PDFjetTextColumn
  Dim Paragraph     As PDFjetParagraph
  Dim TextLine        As PDFjetTextLine
  Dim TextFont       As PDFjetFont

 TextColumn.Initialize                                 <----- This line fails with the error below


** Activity (main) Create, isFirst = true **
Cannot get methods of class: uk.co.martinpearman.b4a.pdfjet.TextColumnWrapper, disabling cache.
Error occurred on line: 110 (Main)
java.lang.RuntimeException: Method: Initialize not found in: uk.co.martinpearman.b4a.pdfjet.TextColumnWrapper
at anywheresoftware.b4a.shell.Shell$MethodCache.getMethod(Shell.java:957)
at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:610)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:739)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
 

warwound

Expert
Licensed User
Longtime User
It looks as though PDFjetTextColumn is only available with the full (paid for) version of PDFjet.
You're using the free open source version are you?
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
When I look at the Open Java Source
B4X:
  /**
  *  Creates page object and add it to the PDF document.
  *
  *  Please note:
  *  <pre>
  *  The coordinate (0f, 0f) is the top left corner of the page.
  *  The size of the pages are represented in points.
  *  1 point is 1/72 inches.
  *  </pre>
  *
  *  @param pdf the pdf object.
  *  @param pageSize the page size of this page.
  */
  public Page(PDF pdf, float[] pageSize) throws Exception {
  this(pdf, pageSize, true);
  }


  /**
  *  Creates page object and add it to the PDF document.
  *
  *  Please note:
  *  <pre>
  *  The coordinate (0f, 0f) is the top left corner of the page.
  *  The size of the pages are represented in points.
  *  1 point is 1/72 inches.
  *  </pre>
  *
  *  @param pdf the pdf object.
  *  @param pageSize the page size of this page.
  *  @param addPageToPDF boolean flag.
  */
  public Page(PDF pdf, float[] pageSize, boolean addPageToPDF) throws Exception {
  this.pdf = pdf;
  contents = new ArrayList<Integer>();
  annots = new ArrayList<Annotation>();
  destinations = new ArrayList<Destination>();
  width = pageSize[0];
  height = pageSize[1];
  buf = new ByteArrayOutputStream(8192);

  if (addPageToPDF) {
  pdf.addPage(this);
  }
  }

There are TWO page Init routines. The Second one takes a Boolean to indicate AddPageToPDF. To me this implies that we can have more than one page.

Is there anyway I can call the second init routine. The XML file has only the first init routine.

BobVal

PS: I just walked thru all the Java open source and to me it appears that AddPage and more than one page should work. But it doesn't. The two routines that do all this are PDF.java and Page.java
 
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Version 5.68

If I try and compile version 5.68 and use it I crash ( PDFJet has stopped working )
if I download the Evaluation version of 5.68 and try it I crash ( PDFJet has stopped working )

Does the 5.68 no longer work with B4A

BobVal
 

RUNO

Active Member
Licensed User
Longtime User
Hello
How do I change print orientation from left to right ?
I want the font type allowed to write Arabic and English.
 
Last edited:

Baris Karadeniz

Active Member
Licensed User
Can I use this library for viewing existing pdf file which is downloaded with webview? There will not be any change on the pdf file.
 

DonManfred

Expert
Licensed User
Longtime User
Can I use this library for viewing existing pdf file which is downloaded with webview?
I think is is only for CREATING PDFs with b4a as stated in Post #1. I don´t think that it can show a PDF but i´m not sure; never used this lib.
 

hibrid0

Active Member
Licensed User
Longtime User
Last edited:

RUNO

Active Member
Licensed User
Longtime User
Hello
How do I change print orientation from left to right ?
I want the font type allowed to write Arabic and English.
 

hibrid0

Active Member
Licensed User
Longtime User
Hello
How do I change print orientation from left to right ?
I want the font type allowed to write Arabic and English.
Right now I dont know, but will help you this sample for B4J and the PDFJet Documentation.
 

Attachments

  • jPDFjet-demo-project.zip
    67 KB · Views: 336
  • java.zip
    170.3 KB · Views: 281

Descartex

Well-Known Member
Licensed User
Longtime User
How can i use (if is possible) to use a font from File.DirAssets???
 

Descartex

Well-Known Member
Licensed User
Longtime User

mokrokuce

Member
Licensed User
Longtime User
Hello Warwound,
I am evaluating this library and I am trying to print these characters: Š Đ Č Ć Ž, but I get only first and last letter.
I am attaching generated PDF file, look at the second line.
Can you point me in the right direction what to do (I am a newbie)?

Thanks.
 

Attachments

  • pdfjet-test.pdf
    1.1 KB · Views: 339
Top