Float text around an image

I am trying to make text float around an image. Initially the text should start at the right of the image but when it reaches the bottom of the image the text should continue underneath the image. See the attachment for an example.

Sofar I have failed to achieve this. Does someone know how this can be done?

Hello André,

Thanks for using our products.

Please try using the following code snippet to accomplish your requirements. The resultant PDF that I have generated is also in attachment. Please take a look.

[C#]

//Instantiate Pdf document object
Pdf pdf1 = new Pdf();
//Create a section in the Pdf
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Instantiate a table object
Table table1 = new Table();
//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(table1);
//Set with column widths of the table
table1.ColumnWidths ="120 250";

//Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
//Set the default cell padding to the MarginInfo object
table1.DefaultCellPadding = margin;

//Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = table1.Rows.Add();

// create an image object
Aspose.Pdf.Image logo = new Aspose.Pdf.Image();
// specify the image file path
logo.ImageInfo.File = @"d:/pdftest/Logo_Image.JPG";
// specify the image Fixed Height
logo.ImageInfo.FixHeight = 120;
// specify the image Fixed Width
logo.ImageInfo.FixWidth= 110;
row1.Cells.Add();
// add the image to paragraphs collection of the table cell
row1.Cells[0].Paragraphs.Add(logo);

//Create string variables with text containing html tags
string TitleString = " Learning at De Baak";
// create a text object to be added to the right of image
Aspose.Pdf.Text TitleText = new Text(TitleString);
TitleText.IsHtmlTagSupported =true;
row1.Cells.Add();
//Add the text paragraphs containing HTML text to the table cell
row1.Cells[1].Paragraphs.Add(TitleText);
// set the vertical alignment of the row contents as Top
row1.VerticalAlignment = Aspose.Pdf.VerticalAlignmentType.Top;

string BodyString1 = "
De Baak is a renowned training evolved from the largest employee (The confederation of Netherland by its Dutch acronym, VNO-NCV) of Dutch business. Founded upon the Humanist training the understanding of the human side of the enterprise.";

/add a text segment to segments collection of the text object
TitleText.Segments.Add(BodyString1);

//Create rows in the table and then cells in the rows
Aspose.Pdf.Row SecondRow = table1.Rows.Add();
SecondRow.Cells.Add();
// set the row span value for Second row as 2
SecondRow.Cells[0].ColumnsSpan = 2;
// Set the vertical alignment of the second row as Top
SecondRow.VerticalAlignment = VerticalAlignmentType.Top;

string SecondRowString = "
De Baak is a renowned training evolved from the largest employee (The confederation of Netherland by its Dutch acronym, VNO-NCV) of Dutch business. Founded upon the Humanist training the understanding of the human side of the enterprise.";Aspose.Pdf.Text SecondRowText = new Aspose.Pdf.Text(SecondRowString);
SecondRowText.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the table cell
SecondRow.Cells[0].Paragraphs.Add(SecondRowText);

pdf1.Save(@"d:/pdftest/LogoWithText_Test.pdf");

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

I would suggest you to please visit the following links for information on topics addressed in the above code snippet.

Silly me, I forgot to mention that we are using XML. But your example is clear. You are using a table to position the text around the image. Although this works it is not a nice solution in our specific case because it would require editors to split up their text into two separate text blocks.

Anyway, if this is the only way to achieve it, we will just have to do it this way.

Thanks for your help.....

Hello André,

Thanks for using our products.

As a workaround you may try using the FloatingBox to accomplish your requirement. In that case you need to create 3 floating boxes and place them accordingly. FloatingBox is a special king of paragraph which is placed on absolute positioning rather than page relative positioning.

For more related information, please visit Working with Floating Box

In case of any further query, please feel free to contact.