Print Page | Close Window

Setting table column widths to accomodate contents

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3704
Printed Date: 02 May 24 at 9:06PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Setting table column widths to accomodate contents
Posted By: Dave K
Subject: Setting table column widths to accomodate contents
Date 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?



Replies:
Posted By: Ingo
Date 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



Posted By: Dave K
Date 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. 


Posted By: Ingo
Date 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



Posted By: Dave K
Date 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 ;-)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk