I have problem with centering some elements in pdf file. Here is a sample project to reproduce the problem:
TestApp.zip (372.0 KB)
Steps to reproduce:
- Open project in VS and run it
- Select a destination folder and press the button
- In the destination folder you will find a res.pdf file
Problems with this pdf:
image.png (25.8 KB)
A: This table inserted into header should be centered. But as you see the left margin is much larger to right one. Also I would like to make width of this table as big as the page width (fit to page)
B: Image also should be centered.
If you need more info, let me know
Thanks
@ManMasterDevelopment
We have modified the CreateHeaderFooter() method in your application as below and generated output PDF is also attached for your kind reference:
HeaderFooter CreateHeaderFooter()
{
// Create a Header Section of the PDF file
Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();
footer.Margin = new MarginInfo(0, 0, 0, 0);
// Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
// Add the table in paragraphs collection of the desired section
footer.Paragraphs.Add(tab1);
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
tab1.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
// Set with column widths of the table
tab1.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = tab1.Rows.Add();
row1.Cells.Add("Left");
row1.Cells.Add("Center");
row1.Cells.Add("Right");
return footer;
}
res.pdf (151.8 KB)
For the image, if you select the image in Adobe Reader, you will notice that it is already in the center. You can also try using another image that is completely filled till its boundaries. In case you still face some issues, please let us know.