setColumnWidth doesn't always seem to work

I have numerous datatables that I import into Aspose.pdf which will have a dynamic number of columns. I am trying to get the PDF document to auto-adjust the column width, but some columns don't seem to adjust correctly, which will lead to the data overrunning the right hand margin of the page. Most of the data is string, and I have even run .trim() on all the data, thinking that it might be related to blank spaces.... but that was not it. Please see the attached document for an example. Also, here is the code snippet of what I am doing. My ultimate goal is to get all the data on one page width, with no line wrapping - preferably to also auto-adjust the font, so no matter how many columns, the full page width will be utilized. Is this possible?

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

// Use Aspose method to set column widths

for (int i = 0; i < dt.Columns.Count; i++)

{

tab1.SetColumnWidth(i, (float)tab1.GetMaxColumnWidth(pdf1, i));

}

Hello Ray,

Thanks for using our products.

I am afraif the method Table.GetMaxXColumnWidth(...) and Table.GetMinColumnWidth(...) are obsolete in recent release versions.

We have recently introduced a new property named DefaultColumnWidth in Table class which can be used to specify the default width for each column of table. I have observed that the customer and Description column width is quite large as compare to its contents. May be you can specify a small width value for these columns that will leave plenty of space for the last column.

The Table class has also a property named IsVerticalBroken which offers the capability to break the table if its printed out of the right page margin. If The sub-table can be place in the same page, it will be placed after the original table in the same page. If the sub-table can't be place in the same page, it will be placed after the original table in the next page.

In case it does not satisfy your requirement or you have any further query, please feel free to contact.

We apologize for your inconvenience.

If the GetMaxColumnWidth() is obsolete, then what did you replace it with - because this definately decreases the functionality of your application? It sounds like to use the DefaultColumnWidth, that I would need to loop through the entire table, and calculate the max width of each column - which is unacceptable since it is usually several thousand rows. I also do not want to split the columns to another page. I want to be able to use some sort of “fit-to-page” function to do this - something that will adjust the font size automatically. I don’t think this is asking a lot, as a lot of programs will do this.

Hello Ray,

I have tested the scenario using Aspose.Pdf for .NET 4.4.0 and I am unable to notice the spacing issue between columns. Can you please share which version of Aspose.Pdf for .NET you are using ?

I have used the attached code snippet to test the scenario. Can you please take a look over it, may be I am missing something. The resultant PDF that I have generated is in attachment, please take a look.

PS, you can download the latest version of Aspose.Pdf for .NET 4.4.0 from here.

Nayyer,

Thanks for the reply. I was running 4.3.0, so downloaded the 4.4.0 and have the same result. I am going to try a .trim() on all my data to make sure there are no spaces causing the issue. We also use Aspose.Cells and the data looks fine in there.

I am still concerned that you have made the method GetMaxColumnWidth obsolete - when will it no longer be availabe? I am sure there are many others that rely on this as well. Are you planning on replacing it with something besides DefaultColumnWidth() (which is still not documented anywhere that I can find)? As I explained earlier, I need something to adjust the column width dynamicly, not something that I have to specify the width of the column. It seems you are reducing the functionality of the app by removing GetMaxColumnWidth.

Also are you planning on implementing a method something like 'fit-to-page' that would automatically adjust the font size so there would be no data running off the page on the right margin? This type feature is present in a lot of apps for printing, so is an important feature that should be included - and I am sure many of your users would agree.

Thanks for your help!

Hello Ray,

Regarding GetMaxColumnWidth(..) method issue, I am in coordination with development team to see if you we fully support this feature back or not and will keep you updated on the status of correction.

Whereas concerning to your requirement on Fit-to-Page method request, I have logged it as PDFNET-17456 in our issue tracking system under new features list. We will further look into the details of this requirement and will keep you updated on the status of correction.

Please spare us little time and we will get back to you, shortly. We are sorry for your inconvenience.

Hello Ray,


Methods GetMaxColumnWidth(int columnNumber) and GetMinColumnWidth(int columnNumber) are obsolete and they will be removed in the next release. But the methods with two parameters (as I can see You use these methods) GetMaxColumnWidth(Pdf pdf, int columnNumber) and GetMaxColumnWidth(Pdf pdf, int columnNumber) will be available.

Hello Ray,

Thanks for your patience.

I am pleased to inform you that as per your requirement, we recently have added a new property named IsFitToPage in Table and Text class and it will be included in our latest release version which will be published sometimes soon. Please be patient and spare us little time.

We apologize for your inconvenience.

The issues you have found earlier (filed as 17456) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.