All Projects → vandeseer → Easytable

vandeseer / Easytable

Licence: mit
Small table drawing library built upon Apache PDFBox

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Easytable

Excalibur
A web interface to extract tabular data from PDFs
Stars: ✭ 916 (+573.53%)
Mutual labels:  pdf, table
Camelot
Camelot: PDF Table Extraction for Humans
Stars: ✭ 3,150 (+2216.18%)
Mutual labels:  pdf, table
Aosa pdf
🚀 The Architecture of Open Source Applications (PDF)
Stars: ✭ 127 (-6.62%)
Mutual labels:  pdf
Pdf To Printer
Print PDF files from Node.js and Electron.
Stars: ✭ 134 (-1.47%)
Mutual labels:  pdf
Documents
收集的程序开发相关的书籍与文档,多数为 PDF 格式文件,欢迎 fork 和 star。
Stars: ✭ 130 (-4.41%)
Mutual labels:  pdf
Docnet
DocNET is as fast PDF editing and reading library for modern .NET applications
Stars: ✭ 128 (-5.88%)
Mutual labels:  pdf
Rapipdf
PDF generation from OpenAPI / Swagger Spec
Stars: ✭ 132 (-2.94%)
Mutual labels:  pdf
Console.table
Adds console.table method that prints an array of objects as a table in console
Stars: ✭ 125 (-8.09%)
Mutual labels:  table
Bootstrap Table
An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
Stars: ✭ 11,068 (+8038.24%)
Mutual labels:  table
Markdown Themeable Pdf
ARCHIVED. NOT MAINTAINED. Themeable Markdown Converter (Print to PDF, HTML, JPEG or PNG)
Stars: ✭ 130 (-4.41%)
Mutual labels:  pdf
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-2.21%)
Mutual labels:  pdf
Pdfcreatorandroid
Simple library to generate and view PDF in Android
Stars: ✭ 128 (-5.88%)
Mutual labels:  pdf
Pdfcompare
A simple Java library to compare two PDF files
Stars: ✭ 128 (-5.88%)
Mutual labels:  pdf
Vue Good Table
An easy to use powerful data table for vuejs with advanced customizations including sorting, column filtering, pagination, grouping etc
Stars: ✭ 1,824 (+1241.18%)
Mutual labels:  table
Nimpdf
PDF document writer, written in nim lang
Stars: ✭ 127 (-6.62%)
Mutual labels:  pdf
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (-1.47%)
Mutual labels:  pdf
Phpchrometopdf
A slim PHP wrapper around google-chrome to convert url to pdf or to take screenshots , easy to use and clean OOP interface
Stars: ✭ 127 (-6.62%)
Mutual labels:  pdf
Importabular
5kb spreadsheet editor for the web, let your users import their data from excel.
Stars: ✭ 129 (-5.15%)
Mutual labels:  table
Pdfview Android
Small Android library to show PDF files
Stars: ✭ 132 (-2.94%)
Mutual labels:  pdf
Vue Xlsx Table
Not need upload, view xlsx or xls file in your browser, Supported by js-xlsx.
Stars: ✭ 136 (+0%)
Mutual labels:  table

easytable

This is a small project that builds upon Apache's PDFBox and should allow you to create tables in a fairly simple way. It emerged from the need in another project. Therefore it also may miss some crucial features. Nevertheless there is:

  • setting font, font size, padding, border width on table, row and cell level
  • setting single cells with bottom-, top-, left- and right-border width separately
  • background color on table, row and cell level
  • padding (top, bottom, left, right) on table, row and cell level
  • border color and style (on table, row or cell level)
  • support for text alignment (right, left, center, justified)
  • vertical text alignment (top, middle, bottom)
  • column spanning and row spanning
  • line breaking and line spacing
  • images in cells
  • experimental: vertical text, links, markup and paragraphs within cells

One can also override classes that are responsible for table/cell drawing, i.e. their drawing behaviour can be customized to a pretty high extent.

It is also possible to draw a table over multiple pages (even with the header row being repeated on every new page).

Installation

Add this to your pom.xml:

<dependency>
    <groupId>com.github.vandeseer</groupId>
    <artifactId>easytable</artifactId>
    <version>0.8.2</version>
</dependency>

Or checkout the repository and install it locally with maven (e.g. for thedevelop branch):

mvn clean install -DskipTests -Dgpg.skip -Ddependency-check.skip=true

Examples

There is a minimal full working example which should help you getting started.

For a bit more involved tables have a look at this code which is needed for creating a PDF document with the following two tables:

easytable table

easytable table

For the next example have a look at the SettingsTest.java:

easytable table

The last one illustrates the use of vertical text in text cells. The code for it can be found here:

easytable table

If you run the tests with mvn clean test there also some PDF documents created which you can find in the target folder. The corresponding sources (in order to understand how to use the code) can be found in the test package.

Paragraph Cells

Since several people asked me to include a way to add hyperlinks within cells I did a bit of research and stumbled across a really nice library named pdfbox-layout. Unfortunately that library will not be developed any further, but it still provides a very powerful API for creating paragraphs with "styled text" (including links as well as markup).

Therefore I created a wrapper cell type (named ParagraphCell) which allows to append

  • hyperlinks
  • styled text (i.e. colorable text with a font and font size) as well as
  • markup (please see this documentation).

Note that the easytable API may be a bit different to what you find in the linked documentation. Anyway, in order to get your hands dirty look at this code on how to create such a table:

table with markup

Adding Needed Dependency

This is still a bit experimental and there may be changes in the future. If you want to use this feature nevertheless you need to add pdfbox-layout as a dependency. In case you are using maven for instance in your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.github.ralfstuckert.pdfbox-layout</groupId>
    <artifactId>pdfbox2-layout</artifactId>
    <version>1.0.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Setting the Page on TableDrawer

Please note that you also need to set the page(...) on the TableDrawer in case you are using a ParagraphCell.

TableDrawer.builder()
    .page(page) // <-- This is needed!
    .contentStream(contentStream)
    .table(table)
    ...
    .build()
    .draw()

Kudos

Q&A

Can I customize the drawers for my own specific needs?

Yep, you can customize the cell drawers itself or (depending on your use case) you can just create a custom cell.

For using a customized cell drawer, have a look at CustomCellDrawerTest.

In case you want to create your own type of cell (which shouldn't really be necessary since the drawing can be completely adapted) you will need to use Lombok's @SuperBuilder annotation. Again, just have a look at the code: CustomCellWithCustomDrawerUsingLombokTest

Can I draw a table over multiple pages?

Yes, have a look at TableOverSeveralPagesTest.java. Just use startY(...) and endY(..) in order to restrict the vertical part of the page where the table should be drawn:

RepeatedHeaderTableDrawer.builder()
    .table(createTable())
    .startX(50)
    .startY(100F)
    .endY(50F) // <-- If the table is bigger, a new page is started
    .build()

Is there a way to repeat the header on every page?

Depending on whether you want to repeat the header row or not you should use RepeatedHeaderTableDrawer or TableDrawer respectively.

Can I get the y coordinate of the end of a drawn table?

Yes. Just use the .getFinalY() method. Also see FinalYTest.java.

Cool, I like it, can I buy you a beer?

Yes. Or you can upvote this answer on stackoverflow. Or:

Donate with PayPal
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].