Free Support Forum - aspose.com

Prevent line break in order to not cutting words or numbers

Hi everyone,
i would have one question.
Is there possible to prevent line break ?
For example, i have in a text a number like 200000$ at the end of the line.
I don’t want to have like “200” at the end of a line and have “000$” on the next one like :

blabla blabla 200
000$ blabla blabla

Thank you all.

Hi,

Thanks for your interest in our products.

In case you are trying to generate PDF document using Aspose.Pdf for .NET, please try using the table component and set the value of IsWordWrapped property of table cell as True so that contents of table cell are not wrapped to next line. Please take a look over the following code snippet and the resultant PDF that I have generated using Aspose.Pdf for .NET 5.3.0

[C#]

// create a PDF object
Pdf pdf1 = new Pdf();
//Create a sectiob object
Aspose.Pdf.Section sec = pdf1.Sections.Add();

// create a table object
Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
// create table object to paragraphs collection of section
sec.Paragraphs.Add(table1);
// specify the column width information
table1.ColumnWidths = "100%";
// create a row object
Row row1 = table1.Rows.Add();
// create a cell object with sample text
Cell cell1Row1 = row1.Cells.Add("This is sample long string text with so much text for the testing of line break using 200000$");
// specify the border information for cell object
cell1Row1.Border = new BorderInfo((int)BorderSide.All, 0.5F);
// specify that words should not wrap if it reaches right border of table cell
cell1Row1.IsWordWrapped = false;
// create another row object
Row row2 = table1.Rows.Add();
// create a cell object with sample text and add it to second row
Cell cell1Row2 = row2.Cells.Add("cell1");
// set the horizontal alignment information for table cell contents
cell1Row2.Alignment = Aspose.Pdf.AlignmentType.Center;
// specify the border information for cell in second row
cell1Row2.Border = new BorderInfo((int)BorderSide.All, 0.5F);

// save the resultant PDF
pdf1.Save(@"d:/pdftest/TextWrapping-test.pdf");

In case I have not properly understood your requirements or you have any further query, please feel free to contact.

Thank you very much for your response, have a nice day :slight_smile: