Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Word wrap in table cells for PDF generation

$
0
0
I have a simple test that shows odd behavior with word wrapping.  If I size the column to just the right size, the PDF will have the last character of the word on the second line.  If I make the column slightly smaller, the entire last word will go to the second line.  If I make it slightly larger, it will all fit on the same line.

Here is the code I used to generate the attached PDF.

using System;
using System.Collections.Generic;
using System.Text;
using Aspose.Pdf;

namespace DummyTestExecutor
{
class PDFWordWrap
{

public static void Main()
{

//Create pdf document
Pdf pdf1 = new Pdf();

Section page = pdf1.Sections.Add();

AddText(page, 204);
AddText(page, 203);
AddText(page, 202);
AddText(page, 201);
AddText(page, 200);

pdf1.Save("c:\\temp\\SimpleLayout1.pdf");

}

private static void AddText(Section page, int columnWidth)
{
Table layout = new Table();
page.Paragraphs.Add(layout);
layout.ColumnWidths = columnWidth.ToString();

Row titleRow = layout.Rows.Add();
titleRow.FixedRowHeight = 40;
Cell tc = titleRow.Cells.Add();

Text text = new Text();

text.Segments.Add(new Segment("Engine: 1.8L I-4 SOHC 16-Valve i-VTEC"));
tc.Paragraphs.Add(text);
}
}
}


Is there something I am doing wrong here?

Viewing all articles
Browse latest Browse all 3131

Trending Articles