diff --git a/README.md b/README.md index 2ac93bcb..9fd220d0 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,18 @@ 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 @@ -38,7 +40,7 @@ Check PRs: com.github.dhorions boxable - 1.5 + 1.6 ``` For other build systems, check the [Maven Central Repository](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22boxable%22). @@ -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) diff --git a/pom.xml b/pom.xml index 82fc2588..39315fff 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 4.0.0 com.github.dhorions boxable - 1.5 + 1.6 jar Boxable, a high-level API to creates table on top of Apache Pdfbox @@ -22,7 +22,7 @@ org.apache.pdfbox pdfbox - 2.0.0 + 2.0.21 compile @@ -34,7 +34,7 @@ com.google.guava guava - 18.0 + 29.0-android compile diff --git a/src/main/java/be/quodlibet/boxable/Table.java b/src/main/java/be/quodlibet/boxable/Table.java index 891e3d16..5683e7c8 100644 --- a/src/main/java/be/quodlibet/boxable/Table.java +++ b/src/main/java/be/quodlibet/boxable/Table.java @@ -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; @@ -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 { public final PDDocument document; @@ -230,11 +227,11 @@ public Row createRow(List> cells, float height) { *

* Draws table *

- * + * * @return Y position of the table * @throws IOException * if underlying stream has problem being written to. - * + * */ public float draw() throws IOException { ensureStreamIsOpen(); @@ -286,7 +283,7 @@ private void drawRow(Row row) throws IOException { row.removeAllBorders(); } - if (isEndOfPage(rowHeight)) { + if (isEndOfPage(rowHeight) && !header.contains(row)) { // Draw line at bottom of table endTable(); @@ -344,7 +341,7 @@ private void drawRow(Row row) throws IOException { *

* Will be removed once {@link #createPage()} is removed. *

- * + * * @return */ private T createNewPage() { @@ -518,7 +515,7 @@ private void drawCellContent(Row 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 @@ -527,7 +524,7 @@ private void drawCellContent(Row 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 @@ -819,7 +816,7 @@ public List getBookmarks() { /** * /** - * + * * @deprecated Use {@link #addHeaderRow(Row)} instead, as it supports * multiple header rows * @param header @@ -838,7 +835,7 @@ public void setHeader(Row header) { *

* IMPORTANT: Doesn't acknowledge possible page break. Use with caution. *

- * + * * @return {@link Table}'s height */ public float getHeaderAndDataHeight() { @@ -854,7 +851,7 @@ public float getHeaderAndDataHeight() { * Calculates minimum table height that needs to be drawn (all header rows + * first data row heights). *

- * + * * @return height */ public float getMinimumHeight() { @@ -879,7 +876,7 @@ public float getMinimumHeight() { *

* Setting current row as table header row *

- * + * * @param row * The row that would be added as table's header row */ @@ -892,7 +889,7 @@ public void addHeaderRow(Row row) { *

* Retrieves last table's header row *

- * + * * @return header row */ public Row getHeader() {