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

How to add border radius for tables #223

Open
diegovdc opened this issue Jul 1, 2022 · 4 comments
Open

How to add border radius for tables #223

diegovdc opened this issue Jul 1, 2022 · 4 comments
Labels

Comments

@diegovdc
Copy link

diegovdc commented Jul 1, 2022

Hello, just wondering if there is a way to add border radius to tables as I don't see this in the documentation.

@yogthos
Copy link
Collaborator

yogthos commented Jul 2, 2022

There isn't a way to set that at the moment, however it wouldn't be too difficult to do if the underlying OpenText API allows for this. Would be a matter of passing a new key here and then setting the field on the table. I might not have time to look at this in the near future, but I'm open to helping with a PR if you'd be up for giving it a shot.

@diegovdc
Copy link
Author

diegovdc commented Jul 4, 2022

Thanks @yogthos, I guess you meant OpenPDF right? As far as I can see the Table class does not have a field for setting the border radius or something similar.

@yogthos
Copy link
Collaborator

yogthos commented Jul 4, 2022

Yeah, it would have to be provided in the OpenPDF API.

@fredgers
Copy link

fredgers commented Mar 13, 2023

iText has a FAQ about this.

The below code worked for me.

(:import [com.lowagie.text.pdf PdfPCellEvent PdfPTable])

(def brdr
  (reify
    PdfPCellEvent
    (cellLayout [this cell rect canvas]
      (let [radius 4
            lineWidth 1.5
            cb (get canvas PdfPTable/BACKGROUNDCANVAS)
            [l b w h] [(.getLeft rect)(.getBottom rect)(.getWidth rect)(.getHeight rect)]]
         (.roundRectangle cb l b w h radius)
         (.setLineWidth cb lineWidth)
         (.stroke cb)))))

[:pdf-cell {:event-handler brdr}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants