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

List in Phrase in PdfTable or PdfCell #149

Open
leontalbot opened this issue Nov 30, 2017 · 7 comments
Open

List in Phrase in PdfTable or PdfCell #149

leontalbot opened this issue Nov 30, 2017 · 7 comments

Comments

@leontalbot
Copy link
Contributor

leontalbot commented Nov 30, 2017

Let's consider the following :pdf-table example

(pdf/pdf
   [{:encoding :unicode}
    [:pdf-table
     {}
     [25 25 25 25]
     [
      ;; Case 1: List
      [:list {:symbol ""} "a" "b" "c"]
      
      ;; Case 2: List in Cell
      [:pdf-cell {} 
       [:list {} "a" "b" "c"]]

      ;; Case 3: List in Phrase - BROKEN
      [:phrase {} [:list {} "a" "b" "c"]]
      
      ;; Case 4: List in nested Paragraphs in Cell - BROKEN
      [:pdf-cell {}
       [:paragraph {} 
        [:paragraph {} "Text" [:spacer 0] "Text"
         [:list {:symbol ""} "a" "b" "c"]]]]]]]
   "doc.pdf")

When the list is inside a Phrase element (cases 3 and 4), it doesn't display correctly (no line breaks between list elements, no symbol prefix)

I took a look at https://github.com/yogthos/clj-pdf/blob/master/src/java/cljpdf/text/pdf/PdfPCell.java
but still can't figure out what to change to make it work.

Could you orient me?

Thank you!

@leontalbot leontalbot changed the title List in Phrase in PdfTable or PDFCell List in Phrase in PdfTable or PdfCell Nov 30, 2017
@yogthos
Copy link
Collaborator

yogthos commented Nov 30, 2017

Unfortunately that code is pretty gnarly, and I wasn't the original author as it's taken from the last LGPL version of iText. I wouldn't be able to advice on this easily, and wouldn't have time to dig into this code in the near future.

@leontalbot
Copy link
Contributor Author

Ok. Thank you :-)

For the record, the following stackoverflow issue seems really similar.
https://stackoverflow.com/questions/28318994/list-items-in-table-cell-are-not-formatted

@leontalbot
Copy link
Contributor Author

leontalbot commented Nov 30, 2017

I finally found a strategy to do it.

We can put a table in a table where the inner table cells has a colspan of 2 for paragraphs and a small left column with a bullet symbol for lists.

Should we create clj-pdf-tools repo to share these kind of transformation helpers?

@yogthos
Copy link
Collaborator

yogthos commented Dec 1, 2017

Yeah that might not be a bad idea, I've used similar tricks to get around formatting problems before myself.

@leontalbot
Copy link
Contributor Author

leontalbot commented Dec 1, 2017

Great!
I suggest we gather the snippets there:
https://github.com/clj-pdf/clj-pdf-tools
Once we feel ready, we could share this lib and invite more people to share their snippets.
Also create a clj-pdf organization and made you Owner. I would like to encourage people to become members and share stuff. Doesn't mean at all we should move clj-pdf...

@yogthos
Copy link
Collaborator

yogthos commented Dec 1, 2017

sounds like a plan, I can move over clj-pdf to the org as well

@Kah0ona
Copy link
Contributor

Kah0ona commented Oct 10, 2018

I now need this as well... Will see if I can get said transformation sort of generic. Of course it's easy to hardcode it as literals, but I need it generated from (a reasonable arbitrary) HTML snippet.

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

No branches or pull requests

3 participants