Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
738 views
in Technique[技术] by (71.8m points)

java - How to create Table using Apache PDFBox

We are planning to migrate our pdf generation utilities from iText to PDFBox (Due to licensing issues in iText). With some effort, I was able to write and position text, draw lines etc. But creating Tables with text embedded in Table cells is a challenge, I went through the documentation, examples, Google, Stackoverflow couldn't find a thing. Was wondering if PDFBox provides native support for creating Tables with embedded text. My last resort would be to use this link https://github.com/eduardohl/Paginated-PDFBox-Table-Sample

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since I also needed table drawing functionality for a side project, I implemented a small "table drawer" library myself, which I uploaded to github.

In order to produce such a table – for instance – ... enter image description here

... you would need this code. In the same file you find the code for that table as well:

enter image description here

The current "feature list" includes:

  • set font and font size on table level as well as on cell level
  • define single cells with bottom-, top-, left- and right-border width separately
  • define the background color on row or cell level
  • define padding (top, bottom, left, right) on cell level
  • define border color (on table, row or cell level)
  • specify text alignment (vertical and horizontal)
  • cell spanning and row spanning
  • text wrapping and line spacing

Also it should not be too hard to add missing stuff like having different border colors for borders on top, bottom, left and right-borders, if needed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...