Automated text cropping within a table cell

Hi everyone,

I searched the doc and this forum but I could not find a quick way to crop the text within a table cell.

Actually, I do have a table with Fixed column widths and Fixed row heights, what I would like is to have my cell content (a simple string on one line) automatically cropped if too large for my cell.

Is there a direct way to do this using aspose pdf ?

Sincerly

Hi Olivier,


Thanks for using our products.

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-33917. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

Hi Olivier,


Thanks for your patience.

Recently we have introduced Table, Row, Cell etc classes under Aspose.Pdf namespace and in order to resolve your issue, I would suggest you to please try using the new classes. Please take a look over the following code snippet based on new classes and for your reference, I have also attached the resultant PDF which I have generated over my end.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

//Instantiate a table object

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

//Add the table in paragraphs collection of the desired section

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "50 50 50";

//Set default cell border using BorderInfo object

tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);

//Set table border using another customized BorderInfo object

tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);

//Create MarginInfo object and set its left, bottom, right and top margins

Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();

margin.Top = 5f;

margin.Left = 5f;

margin.Right = 5f;

margin.Bottom = 5f;

//Set the default cell padding to the MarginInfo object

tab1.DefaultCellPadding = margin;

//Create rows in the table and then cells in the rows

Aspose.Pdf.Row row1 = tab1.Rows.Add();

row1.Cells.Add("col1");

row1.Cells.Add("col2");

row1.Cells.Add();

TextFragment mytext = new TextFragment("col3 with large text string");

//row1.Cells.Add("col3 with large text string to be placed inside cell");

row1.Cells[2].Paragraphs.Add(mytext);

row1.Cells[2].IsWordWrapped = false;

//row1.Cells[2].Paragraphs[0].FixedWidth= 80;

Aspose.Pdf.Row row2 = tab1.Rows.Add();

row2.Cells.Add("item1");

row2.Cells.Add("item2");

row2.Cells.Add("item3");

//Save the Pdf

doc.Save(“c:/pdftest/33917.pdf”);

The issues you have found earlier (filed as PDFNEWNET-33917) have been fixed in Aspose.Pdf for .NET 7.7.0.


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