Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table class overhauled, main package cleaned up. #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .classpath

This file was deleted.

25 changes: 4 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
*.pdf
build/*
dist/*
*.class
lib/*
nbproject/*
build.xml
manifest.mf
# Package Files #
*.jar
*.war
*.ear

.idea
target
*.iml
/target/
/bin/
/build/
.settings
.gradle
.metadata
settings.xml
.project
.classpath
/.settings/
25 changes: 0 additions & 25 deletions .project

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml

This file was deleted.

32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
[Boxable](http://dhorions.github.io/boxable/) - A java library to build tables in PDF documents.
=======

[![Join the chat at https://gitter.im/dhorions/boxable](https://badges.gitter.im/dhorions/boxable.svg)](https://gitter.im/dhorions/boxable?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/dhorions/boxable.svg?branch=master)](https://travis-ci.org/dhorions/boxable)


Boxable is a library that can be used to easily create tables in pdf documents. It uses the [PDFBox](https://pdfbox.apache.org/) PDF library under the hood.

# Changelog
This fork was made as part of a university project. These changes have been implemented:
* Removed abstract modifier from Table class to allow it to be instantiated directly. This is less confusing than instantiating through BaseTable, and allows the user to employ the \<T extends PDPage> generic functionality without writing their own Table sub-class.
* Split Table\<T> into two classes (as it was huge, and had too many responsibilities):
* TableDrawer\<T> does all of the drawing and nothing else. Its only public method is draw().
* Table stores the styling and the Rows.
This change makes it easier to write the same table to different documents and makes the code easier to understand.
* Added Table.Builder for more user-friendly construction of Table objects.
* TableDrawer\<T> is now the only class which interacts with PageProvider\<T>, so the \<T> parameterisation was removed from the Table, Row, and Cell classes.
* BaseTable now acts as an adapter for sending deprecated method calls to the new objects.

Cleaned up root of main package:
* Moved ImageCell class into Image sub-package.
* Moved HTMLNode and TableCell into new HTML sub-package.
* Deleted deprecated BoxableUtils class.
* Deleted dead classes (AbstractPageTemplate, AbstractTemplatedTable).


Made building from source easier:
* Removed Gradle, left Maven. Couldn't get it to import into Eclipse error-free with both build tools present.
* Added .project, .classpath, .settings files to .gitignore.

Miscellaneous fixes:
* Replaced deprecated PDPageContentStream constructors
* Fixed some outdated header checks
* Removed Guava dependency as it was barely doing anything

# Features

- Build tables in pdf documents
Expand Down
36 changes: 0 additions & 36 deletions build.gradle

This file was deleted.

14 changes: 4 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.dhorions</groupId>
<artifactId>boxable</artifactId>
<version>1.5</version>
<version>1.6</version>
<packaging>jar</packaging>

<name>Boxable, a high-level API to creates table on top of Apache Pdfbox</name>
Expand All @@ -31,12 +31,6 @@
<version>1.7.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
Expand Down Expand Up @@ -87,10 +81,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>10</source>
<target>10</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/be/quodlibet/boxable/AbstractPageTemplate.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/be/quodlibet/boxable/AbstractTemplatedTable.java

This file was deleted.

82 changes: 63 additions & 19 deletions src/main/java/be/quodlibet/boxable/BaseTable.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,77 @@
package be.quodlibet.boxable;

import java.io.IOException;
import java.util.Collection;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;

import be.quodlibet.boxable.page.DefaultPageProvider;
import be.quodlibet.boxable.page.PageProvider;


/**
* Created by dgautier on 3/18/2015.
* Deprecated: this class now acts as a temporary adapter for the new Table/TableDrawer system
*/
public class BaseTable extends Table<PDPage> {

public BaseTable(float yStart, float yStartNewPage, float bottomMargin, float width, float margin, PDDocument document, PDPage currentPage, boolean drawLines, boolean drawContent) throws IOException {
super(yStart, yStartNewPage, 0, bottomMargin, width, margin, document, currentPage, drawLines, drawContent, new DefaultPageProvider(document, currentPage.getMediaBox()));
}

public BaseTable(float yStart, float yStartNewPage, float pageTopMargin, float bottomMargin, float width, float margin, PDDocument document, PDPage currentPage, boolean drawLines, boolean drawContent) throws IOException {
super(yStart, yStartNewPage, pageTopMargin, bottomMargin, width, margin, document, currentPage, drawLines, drawContent, new DefaultPageProvider(document, currentPage.getMediaBox()));
}

public BaseTable(float yStart, float yStartNewPage, float pageTopMargin, float bottomMargin, float width, float margin, PDDocument document, PDPage currentPage, boolean drawLines, boolean drawContent, final PageProvider<PDPage> pageProvider) throws IOException {
super(yStart, yStartNewPage, pageTopMargin, bottomMargin, width, margin, document, currentPage, drawLines, drawContent, pageProvider);
}

@Override
protected void loadFonts() {
// Do nothing as we don't have any fonts to load
}
@Deprecated
public class BaseTable {
public Table table;
public TableDrawer<PDPage> tableDrawer;

public BaseTable(float yStart, float yStartNewPage, float bottomMargin, float width, float
margin, PDDocument document, PDPage currentPage, boolean drawLines, boolean drawContent) throws IOException {
table = new Table.Builder()
.yStart(yStart)
.yStartNewPage(yStartNewPage)
.pageTopMargin(0)
.pageBottomMargin(bottomMargin)
.width(width)
.margin(margin)
.drawLines(drawLines)
.drawContent(drawContent)
.build();
tableDrawer = new TableDrawer<PDPage>(table, document, currentPage, new DefaultPageProvider(document, currentPage.getMediaBox()));
//document
}
public BaseTable(float yStart, float yStartNewPage, float pageTopMargin, float bottomMargin, float width,
float margin, PDDocument document, PDPage currentPage, boolean drawLines, boolean drawContent) throws IOException {
table = new Table.Builder()
.yStart(yStart)
.yStartNewPage(yStartNewPage)
.pageTopMargin(pageTopMargin)
.pageBottomMargin(bottomMargin)
.width(width)
.margin(margin)
.drawLines(drawLines)
.drawContent(drawContent)
.build();
tableDrawer = new TableDrawer<PDPage>(table, document, currentPage, new DefaultPageProvider(document, currentPage.getMediaBox()));
}

public void addHeaderRow(Row row) {
table.addHeaderRow(row);
}

public Row createRow(float f) {
return table.createRow(f);
}

public void draw() {
try {
tableDrawer.draw();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Collection<? extends PDOutlineItem> getBookmarks() {
return tableDrawer.getBookmarks();
}
public void removeAllBorders(boolean b) {
tableDrawer.removeAllBorders(b);
}
public void setLineSpacing(float f) {
tableDrawer.setLineSpacing(f);
}
}
30 changes: 0 additions & 30 deletions src/main/java/be/quodlibet/boxable/BoxableUtils.java

This file was deleted.

Loading