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 - Setting table column widths to accomodate contents
  FAQ FAQ  Forum Search   Register Register  Login Login

Setting table column widths to accomodate contents

 Post Reply Post Reply
Author
Message
Dave K View Drop Down
Beginner
Beginner


Joined: 03 May 19
Location: Torquay
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dave K Quote  Post ReplyReply Direct Link To This Post Topic: Setting table column widths to accomodate contents
    Posted: 03 May 19 at 3:28PM
Hello,

I am new to Debenu quick pdf library. I am writing software for my company that involves extracting data from Excel files and ultimately producing PDF documents that among other contents contain tabular data. At first I was thinking that I would have to be writing strings of text out on to a page and manually drawing the table cells... Then I found out about using tables built into the library...

If I create a table with several columns and then populate the cells with strings of various lengths, is there a built in way to set the column widths to accommodate the longest width needed for a cell in that column? Or must I first iterate over the strings and use e.g. GetHTMLTextWidth() to find the longest before creating the table?

Or is it recommended to set the column widths using SetTableColumnWidth() dynamically as the data is added - using the longest so far measured value?
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 19 at 11:01PM
Hi Dave,

After using DrawHTMLText...
https://www.debenu.com/docs/pdf_library_reference/DrawHTMLText.php
...you can use GetHTMLTextWidth...
https://www.debenu.com/docs/pdf_library_reference/GetHTMLTextWidth.php
...toget the width of the textstring you've actually drawn.

I think you've already found the Debenu-online-ressources for the first steps, developer guide, samples and so on?

Cheers and welcome here,
Ingo


Cheers,
Ingo

Back to Top
Dave K View Drop Down
Beginner
Beginner


Joined: 03 May 19
Location: Torquay
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dave K Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 19 at 9:46AM
Hi Ingo,

Thanks, the procedure you're outlining there is pretty much how I was originally thinking it would work.

But then I saw the functions CreateTable(), SetTableCellContent() and DrawTableRows() etc.

I can see how I can use these table handling functions to create tables in an efficient way- but only if the cell sizes are known before hand. It just seemed like I must be missing something if that's the only way these functions work. Is there a way of using the table functions in such a way so that the library computes the required cell sizes as the data is added to the table using SetTableCellContent etc? 

Or is the only way to do it that I collect all of the data before hand and determine the required sizes before creating the table? It seemed to me that if tables had been added to the library as an object for convenience then it is likely the table could auto fit to the data that's added to it - and I'm just missing the information on how to use it that way?

I do have the developer guide and reference but I couldn't find much in those to do with the intended collective use of the table functions. I will eventually get to the point where I can experiment with how to do this properly - but I was just hoping that its common knowledge already. 
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 19 at 4:46PM
Hi Dave,

the cell denitions are fix.
What you can do is making the text floating ;-)

Cheers,
Ingo

Back to Top
Dave K View Drop Down
Beginner
Beginner


Joined: 03 May 19
Location: Torquay
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dave K Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 19 at 4:59PM
Hi Ingo,

I'm not quite sure what your intended meaning is for that. But thanks for your help anyway ;-)
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