We are trying to align an image in a table with halign=“right” but it doesn’t get applied.
This is the reproducer code
using System;
using System.IO;
using Aspose.Pdf;
using Aspose.Pdf.Generator;
using Aspose.Pdf.Text;
using Cell = Aspose.Pdf.Cell;
using Image = Aspose.Pdf.Image;
using Table = Aspose.Pdf.Table;
namespace Aspose
{
public class Program
{
public static void Main(string[] args)
{
// Reproducer for issue: https://gitlab.factset.com/dexter/dexter/issues/105
var doc = new Document(); // create document
var page = doc.Pages.Add(); // add a page to the document’s collection of pages
var mytable = new Table(); // Instantiate a table object
mytable.ColumnWidths = "80% 20%"; // Set with column widths of the table
page.Paragraphs.Add(mytable); // Add the table in paragraphs collection of the desired section
var firstRow = mytable.Rows.Add(); // Add a row to the table’s collection of rows
var firstCell = firstRow.Cells.Add(); // Add a cell to the row’s collection of cells
// create image, read from file, set properties
var img = new Image();
img.File = Path.Combine(Directory.GetCurrentDirectory(), "image.png");
img.FixHeight = 10.0;
img.FixWidth = 10.0;
firstCell.Alignment = HorizontalAlignment.Right; // set the alignment of the cell
firstCell.Paragraphs.Add(img);
// create the second cell in the first row with text
var secondCell = firstRow.Cells.Add();
var secondCellText = new TextFragment();
secondCellText.Text = "Right Aligned";
secondCell.Alignment = HorizontalAlignment.Right;
secondCell.Paragraphs.Add(secondCellText);
doc.Save("ImageNotAligned.pdf");
}
}
}