Code Monkey home page Code Monkey logo

boxable's Introduction

Boxable - A java library to build tables in PDF documents.

Join the chat at https://gitter.im/dhorions/boxable Build Status Donate

Boxable is a library that can be used to easily create tables in pdf documents. It uses the PDFBox PDF library under the hood.

Features

  • Build tables in pdf documents
  • Convert csv data into tables in pdf documents
  • Convert Lists into tables in pdf documents

Boxable supports next tables features

  • HTML tags in cell content (not all! <p>,<i>,<b>,<br>,<ul>,<ol>,<li>)
  • Horizontal & Vertical Alignment of the text
  • Images inside cells and outside table (image scale is also supported)
  • basic set of rendering attributes for lines (borders)
  • rotated text (by 90 degrees)
  • writing text outside tables

Maven

<dependency>
    <groupId>com.github.dhorions</groupId>
    <artifactId>boxable</artifactId>
    <version>1.7.0</version>
</dependency>

For other build systems, check the Maven Central Repository.

Tutorial

A tutorial is being created and will be accessible at https://github.com/dhorions/boxable/wiki. If you want to help, please let us know here.

Usage examples

Create a pdf from a csv file

String data = readData("https://s3.amazonaws.com/misc.quodlibet.be/Boxable/Eurostat_Immigration_Applications.csv");
BaseTable pdfTable = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true,true);
DataTable t = new DataTable(pdfTable, page);
t.addCsvToTable(data, DataTable.HASHEADER, ';');
pdfTable.draw();

Output : CSVExamplePortrait.pdf

Create a pdf from a List

List<List> data = new ArrayList();
data.add(new ArrayList<>(
               Arrays.asList("Column One", "Column Two", "Column Three", "Column Four", "Column Five")));
for (int i = 1; i <= 100; i++) {
  data.add(new ArrayList<>(
      Arrays.asList("Row " + i + " Col One", "Row " + i + " Col Two", "Row " + i + " Col Three", "Row " + i + " Col Four", "Row " + i + " Col Five")));
}
BaseTable dataTable = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, true);
DataTable t = new DataTable(dataTable, page);
t.addListToTable(data, DataTable.HASHEADER);
dataTable.draw();

Output : ListExampleLandscape.pdf

Build tables in pdf documents

BaseTable table = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true,
				drawContent);
//Create Header row
Row<PDPage> headerRow = table.createRow(15f);
Cell<PDPage> cell = headerRow.createCell(100, "Awesome Facts About Belgium");
cell.setFont(PDType1Font.HELVETICA_BOLD);
cell.setFillColor(Color.BLACK);
table.addHeaderRow(headerRow);
List<String[]> facts = getFacts();
for (String[] fact : facts) {
			Row<PDPage> row = table.createRow(10f);
			cell = row.createCell((100 / 3.0f) * 2, fact[0] );
			for (int i = 1; i < fact.length; i++) {
			   cell = row.createCell((100 / 9f), fact[i]);
			}
}
table.draw();

Special Thanks to these awesome contributers :

=======

Copyright 2022

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

boxable's People

Contributors

frulenzo avatar dhorions avatar dgautier avatar vobarian avatar johnmanko avatar cschemmy avatar rachidlelaborantin avatar zeerdonker avatar dependabot[bot] avatar dobluth avatar slampisko avatar schmitzhermes avatar zaqpiotr avatar theeogflip avatar dev-comrade avatar gitter-badger avatar sz-liva avatar bryant1410 avatar reiz avatar giboow avatar aldaris avatar sundbp avatar nstdspace avatar mdu39170 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.