Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - How to handle table cells with large text
  FAQ FAQ  Forum Search   Register Register  Login Login

How to handle table cells with large text

 Post Reply Post Reply
Author
Message
bpeikes View Drop Down
Beginner
Beginner


Joined: 23 Apr 18
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote bpeikes Quote  Post ReplyReply Direct Link To This Post Topic: How to handle table cells with large text
    Posted: 28 Jun 23 at 5:10AM
We've got code for rendering tables across multiple pages, with repeating headers. There is one place where we are having some issues with though, and that is if a cell has so much text it does not fit on a single page.

What's the best way of handling this? Our code currently checks to see the last row rendered, and if there are any more rows to render, starts a new page, (optionally renders header by inserting a row) and then continues to render the table.

When a string in a cell is too long, DrawTableRows returns the height of the header row, and since we still have rows to process, we create a new page, and render a header, etc....

To add some complications, we are adding html line break into some of the fields, based on if the user has entered multiline text.
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jun 23 at 10:45AM
It is difficult to advise you without knowing how you plan to deal with a cell that does not fit on a page -  how will you deal with splitting it or reducing its size. My approach would be to start by making the header row an entirely separate 1-row table on each page, to avoid modifying the table while you are rendering it. I am a bit surprised that that even works.  But then you have a number of options when 0 rows fit, including omitting the header table on that page and trying again; rendering the too-large content in a separate 1-row table with a smaller font and skipping that row for the next page in the main table; finding a way of splitting it; or something else. Again, the details of how you implement your solution is totally dependent on what you decide your solution will be for your specific content and audience.
Back to Top
bpeikes View Drop Down
Beginner
Beginner


Joined: 23 Apr 18
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote bpeikes Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jun 23 at 2:09PM
It sounds like the library does not have a way to render tables across pages then.

I would want the row to continue to be rendered on the next page, or have the abilty to clip the text.

Are you saying that if we add a new page to have a table render across multiple pages, we should start a new table? That doesnt feasable if you are trying to render a table with hundreds of rows across multiple pages.
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jun 23 at 10:25AM
No, I was not saying start a new table. It seems reasonable to me that handling a "row" which needs more than a page should not be a built-in feature of a function designed to handle "tables" in general. The function handles pagination quite well, but this seems a special case, especially since you said that some of these big rows may also contain HTML in which line-breaks are present.

So my suggestion was that you deal with an outlier row needing an internal page break independently of the table function, and then carry on rendering the rest of the original table on later pages. How you handle this special row depends on your application. It seems that it should be straightforward to do this, but this depends on how complicated the content is. That's my response to your original question, but there may be other users here who have more experience with "tables" than I do.

You will find that QPDF has functionality in many unexpected areas, but this task may be stretching its capability!
Back to Top
bpeikes View Drop Down
Beginner
Beginner


Joined: 23 Apr 18
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote bpeikes Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jun 23 at 6:41PM
The main issue I'm having is that there isn't a good way to know how to split it up. The call DrawHTMLTextBox returns the remainder of the html that wont fit into the box, and there is another function GetHTMLTextHeight, that will give you the height of the box needed to render HTML.

The issue is that there is no call where you can specify a box, and get information about what part of of the HTML that wont fit in a box.

If that was the case, then I could find which column was causing the row to not be drawn, split the text, and then copy the remainder into the new row.

Back to Top
bpeikes View Drop Down
Beginner
Beginner


Joined: 23 Apr 18
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote bpeikes Quote  Post ReplyReply Direct Link To This Post Posted: 28 Aug 23 at 2:55PM
I noticed that you said "the function handles pagination quite well". Which function handles pagination well?
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 31 Aug 23 at 6:26PM
The one you are asking about: DrawTableRows.  It is fine if you have smallish rows and do not mind about leaving a bit of blank space at the bottom when a row does not fit. But if you want to divide up the text in a row and split it across multiple pages, you have to decide on your policy for splitting it, and then perhaps use a function such as DrawHTMLTextBox to fill the gap, which will return the LeftOverText which will then fit on the next page. It will involve some experimentation to get it to work as you want, but with this function, QPDF does provides "a call where you can specify a box, and get information about what part of of the HTML that wont fit in a box".  You might have to do a test render on a spare page to get this function to tell you where to split the text, before to adding it to the table, but it seems that QPDF can split it for you. The documentation does not say how smart it is about not splitting in the middle of words, but if you discover a split word you could always move all of it to the next page.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store