Skip to content

Commit

Permalink
Merge pull request #203 from dhorions/1.6-preparation
Browse files Browse the repository at this point in the history
1.6 preparation
  • Loading branch information
dhorions committed Aug 29, 2020
2 parents b18ff58 + ed11c0e commit ba969ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,26 @@ Boxable is a library that can be used to easily create tables in pdf documents.
- rotated text (by 90 degrees)
- writing text outside tables

#### What is new in version 1.5?
- several HTML ordered lists bugfixes
- having possibility to make inner tables with TableCell (check `SampleTest10()` JUnit test)
- using FreeSans as default font to avoid multiple charachter decoding problems
- added support for drawing "borderless" table (check `SampleTest11()` for that)
- javadocs bugfix
#### What is new in version 1.6?
- performance optimizations by [@Vobarian](https://github.com/vobarian)
- reduced pdf file output size by [@Vobarian](https://github.com/vobarian) and [@Giboow](https://github.com/giboow)
- fix for infinite loop when header rows were below page bottom margin. [@Ogmios-Voice](https://github.com/ogmios-voice)
- added COPYING file [@zaqpiotr](https://github.com/zaqpiotr)
- Updated pdfbox library to 2.0.21
- Updated guava library to 29-android

Check PRs:
[#142](https://github.com/dhorions/boxable/pull/142)
[#144](https://github.com/dhorions/boxable/pull/144)
[#183](https://github.com/dhorions/boxable/pull/183)
[#202](https://github.com/dhorions/boxable/pull/202)
[#190](https://github.com/dhorions/boxable/pull/190)


# Maven
```xml
<dependency>
<groupId>com.github.dhorions</groupId>
<artifactId>boxable</artifactId>
<version>1.5</version>
<version>1.6</version>
</dependency>
```
For other build systems, check the [Maven Central Repository](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22boxable%22).
Expand Down Expand Up @@ -102,6 +104,10 @@ table.draw();
```

Special Thanks to these awesome contributers :
- [@Vobarian](https://github.com/vobarian)
- [@Giboow](https://github.com/giboow)
- [@Ogmios-Voice](https://github.com/ogmios-voice)
- [@zaqpiotr](https://github.com/zaqpiotr)
- [Frulenzo](https://github.com/Frulenzo)
- [dgautier](https://github.com/dgautier)
- [ZeerDonker](https://github.com/ZeerDonker)
Expand Down
6 changes: 3 additions & 3 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 @@ -22,7 +22,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.0</version>
<version>2.0.21</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -34,7 +34,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<version>29.0-android</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
39 changes: 18 additions & 21 deletions src/main/java/be/quodlibet/boxable/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
*/
package be.quodlibet.boxable;

import be.quodlibet.boxable.line.LineStyle;
import be.quodlibet.boxable.page.PageProvider;
import be.quodlibet.boxable.text.Token;
import be.quodlibet.boxable.text.WrappingFunction;
import be.quodlibet.boxable.utils.FontUtils;
import be.quodlibet.boxable.utils.PDStreamUtils;
import be.quodlibet.boxable.utils.PageContentStreamOptimized;
import static com.google.common.base.Preconditions.checkNotNull;

import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import be.quodlibet.boxable.utils.PageContentStreamOptimized;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
Expand All @@ -22,13 +26,6 @@
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageXYZDestination;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;

import be.quodlibet.boxable.line.LineStyle;
import be.quodlibet.boxable.page.PageProvider;
import be.quodlibet.boxable.text.Token;
import be.quodlibet.boxable.text.WrappingFunction;
import be.quodlibet.boxable.utils.FontUtils;
import be.quodlibet.boxable.utils.PDStreamUtils;

public abstract class Table<T extends PDPage> {

public final PDDocument document;
Expand Down Expand Up @@ -230,11 +227,11 @@ public Row<T> createRow(List<Cell<T>> cells, float height) {
* <p>
* Draws table
* </p>
*
*
* @return Y position of the table
* @throws IOException
* if underlying stream has problem being written to.
*
*
*/
public float draw() throws IOException {
ensureStreamIsOpen();
Expand Down Expand Up @@ -286,7 +283,7 @@ private void drawRow(Row<T> row) throws IOException {
row.removeAllBorders();
}

if (isEndOfPage(rowHeight)) {
if (isEndOfPage(rowHeight) && !header.contains(row)) {

// Draw line at bottom of table
endTable();
Expand Down Expand Up @@ -344,7 +341,7 @@ private void drawRow(Row<T> row) throws IOException {
* <p>
* Will be removed once {@link #createPage()} is removed.
* </p>
*
*
* @return
*/
private T createNewPage() {
Expand Down Expand Up @@ -518,7 +515,7 @@ private void drawCellContent(Row<T> row, float rowHeight) throws IOException {
- (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth());

if (drawDebug) {
// @formatter:off
// @formatter:off
// top padding
PDStreamUtils.rect(tableContentStream, cursorX + (cell.getLeftBorder() == null ? 0 : cell.getLeftBorder().getWidth()), yStart - (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth()), cell.getWidth() - (cell.getLeftBorder() == null ? 0 : cell.getLeftBorder().getWidth()) - (cell.getRightBorder() == null ? 0 : cell.getRightBorder().getWidth()), cell.getTopPadding(), Color.RED);
// bottom padding
Expand All @@ -527,7 +524,7 @@ private void drawCellContent(Row<T> row, float rowHeight) throws IOException {
PDStreamUtils.rect(tableContentStream, cursorX + (cell.getLeftBorder() == null ? 0 : cell.getLeftBorder().getWidth()), yStart - (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth()), cell.getLeftPadding(), cell.getHeight() - (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth()) - (cell.getBottomBorder() == null ? 0 : cell.getBottomBorder().getWidth()), Color.RED);
// right padding
PDStreamUtils.rect(tableContentStream, cursorX + cell.getWidth() - (cell.getRightBorder() == null ? 0 : cell.getRightBorder().getWidth()) , yStart - (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth()), -cell.getRightPadding(), cell.getHeight() - (cell.getTopBorder() == null ? 0 : cell.getTopBorder().getWidth()) - (cell.getBottomBorder() == null ? 0 : cell.getBottomBorder().getWidth()), Color.RED);
// @formatter:on
// @formatter:on
}

// respect left padding
Expand Down Expand Up @@ -819,7 +816,7 @@ public List<PDOutlineItem> getBookmarks() {

/**
* /**
*
*
* @deprecated Use {@link #addHeaderRow(Row)} instead, as it supports
* multiple header rows
* @param header
Expand All @@ -838,7 +835,7 @@ public void setHeader(Row<T> header) {
* <p>
* IMPORTANT: Doesn't acknowledge possible page break. Use with caution.
* </p>
*
*
* @return {@link Table}'s height
*/
public float getHeaderAndDataHeight() {
Expand All @@ -854,7 +851,7 @@ public float getHeaderAndDataHeight() {
* Calculates minimum table height that needs to be drawn (all header rows +
* first data row heights).
* </p>
*
*
* @return height
*/
public float getMinimumHeight() {
Expand All @@ -879,7 +876,7 @@ public float getMinimumHeight() {
* <p>
* Setting current row as table header row
* </p>
*
*
* @param row
* The row that would be added as table's header row
*/
Expand All @@ -892,7 +889,7 @@ public void addHeaderRow(Row<T> row) {
* <p>
* Retrieves last table's header row
* </p>
*
*
* @return header row
*/
public Row<T> getHeader() {
Expand Down

0 comments on commit ba969ad

Please sign in to comment.