Changing page ordering when table spans page horizontally

I am using the NuGet trial version of Aspose.Pdf to check the product it is capable of replacing our existing solution.

I have one outstanding issue relating to the ability to change the page ordering when a table spans multiple pages horizontally. The default appears to be down then across. I need to go across and then down.

I have read through other articles trying to get the terminology right but have not found an answer. Can anyone help?

@MaccShaun

Thank you for contacting Aspose Support.

I have one outstanding issue relating to the ability to change the page ordering when a table spans multiple pages horizontally.

Have you raised this issue with us earlier? If yes I would find the relevant JIRA task and update you accordingly.

If not, we would appreciate if you could share an input file and the expected output file to ensure we are on the same page. Please also share the sample code that you are using to perform the required task.

Thank you for your reply.

No, this is not an existing issue. I used the word ‘outstanding’ to show my issue not yours.

In summary, I am using Aspose.Pdf to replace an existing engine to generate NEW PDFs so there is not input file.

Code snippet:

`Aspose.Pdf.Document doc = new Aspose.Pdf.Document();

doc.Info.Author = “Company Name”;

var page = doc.Pages.Add();

page.PageInfo.Margin = new MarginInfo(15, 50, 15, 50);

page.Header = new HeaderFooter();
page.Header.Margin = new MarginInfo(15, 0, 15, 0);

Aspose.Pdf.Table hdrTable = new Aspose.Pdf.Table();

int imageSize = 35;
int width2Use = (int)(!page.PageInfo.IsLandscape ? page.PageInfo.Width : page.PageInfo.Height);
int twentyPercent = (int)(width2Use / 5);
int thirtyPercent = (int)((width2Use / 10) * 3);
int fortyPercent = (int)((width2Use / 10) * 4);
int sixtyPercent = (int)(width2Use - (2 * twentyPercent));

hdrTable.ColumnWidths = string.Format("{0} {1} {2} {3}", imageSize, thirtyPercent - imageSize, fortyPercent, thirtyPercent);
hdrTable.DefaultCellPadding = new MarginInfo(0, 2, 0, 2);
hdrTable.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));

Aspose.Pdf.Row hdrRow = hdrTable.Rows.Add();

hdrRow.DefaultCellTextState.Font = FontRepository.FindFont(“TimesNewRoman”);
hdrRow.DefaultCellTextState.FontSize = 11;
hdrRow.DefaultCellTextState.FontStyle = FontStyles.Bold;

Aspose.Pdf.Image image = new Aspose.Pdf.Image();
image.File = “PrintLogo.bmp”;
image.FixHeight = imageSize;
image.FixWidth = imageSize;

hdrRow.Cells.Add();
hdrRow.Cells[0].Paragraphs.Add(image);
hdrRow.Cells[0].RowSpan = 2;
hdrRow.Cells[0].Alignment = HorizontalAlignment.Left;
hdrRow.Cells.Add(“Company Name”);
hdrRow.Cells[1].Alignment = HorizontalAlignment.Left;
hdrRow.Cells[1].DefaultCellTextState.FontSize = 16;
hdrRow.Cells[1].DefaultCellTextState.Font = FontRepository.FindFont(“Arial”);
hdrRow.Cells[1].Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
hdrRow.Cells.Add(“Report Title”);
hdrRow.Cells[2].Alignment = HorizontalAlignment.Center;
hdrRow.Cells[2].RowSpan = 2;
hdrRow.Cells[2].VerticalAlignment = VerticalAlignment.Center;
hdrRow.Cells.Add(“USERNAME”);
hdrRow.Cells[3].Alignment = HorizontalAlignment.Right;
hdrRow.Cells[3].RowSpan = 2;
hdrRow.Cells[3].VerticalAlignment = VerticalAlignment.Center;

hdrRow = hdrTable.Rows.Add();

hdrRow.DefaultCellTextState.Font = FontRepository.FindFont(“TimesNewRoman”);
hdrRow.DefaultCellTextState.FontSize = 11;
hdrRow.DefaultCellTextState.FontStyle = FontStyles.Bold;

hdrRow.Cells.Add(“Service Name”);
hdrRow.Cells[0].Alignment = HorizontalAlignment.Left;

page.Header.Paragraphs.Add(hdrTable);

page.Footer = new HeaderFooter();
page.Footer.Margin = new MarginInfo(15, 0, 15, 0);

Aspose.Pdf.Table ftrTable = new Aspose.Pdf.Table();

ftrTable.ColumnWidths = string.Format("{0} {1} {0}", twentyPercent, sixtyPercent);
ftrTable.DefaultCellPadding = new MarginInfo(0, 1, 0, 1);
ftrTable.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Top, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));

Aspose.Pdf.Row ftrRow = ftrTable.Rows.Add();

ftrRow.DefaultCellTextState.Font = FontRepository.FindFont(“TimesNewRoman”);
ftrRow.DefaultCellTextState.FontSize = 10;
ftrRow.DefaultCellTextState.FontStyle = FontStyles.Bold;

ftrRow.Cells.Add(“Version : 9.99.9.999”);
ftrRow.Cells[0].Alignment = HorizontalAlignment.Left;
ftrRow.Cells.Add(“This report is confidential and for the intended recipient only.”);
ftrRow.Cells[1].Alignment = HorizontalAlignment.Center;
ftrRow.Cells[1].DefaultCellTextState.FontSize = 9;
ftrRow.Cells.Add(System.DateTime.Now.ToString(“dd/MM/yy HH:mm.ss”));
ftrRow.Cells[2].Alignment = HorizontalAlignment.Right;

ftrRow = ftrTable.Rows.Add();

ftrRow.DefaultCellTextState.Font = FontRepository.FindFont(“TimesNewRoman”);
ftrRow.DefaultCellTextState.FontSize = 10;
ftrRow.DefaultCellTextState.FontStyle = FontStyles.Bold;

ftrRow.Cells.Add(string.Empty);
ftrRow.Cells[0].Alignment = HorizontalAlignment.Left;
ftrRow.Cells.Add(“If you are not the intended recipient please destroy this page immediately.”);
ftrRow.Cells[1].Alignment = HorizontalAlignment.Center;
ftrRow.Cells[1].DefaultCellTextState.FontSize = 9;
ftrRow.Cells.Add(“Page $p-$P”);
ftrRow.Cells[2].Alignment = HorizontalAlignment.Right;

page.Footer.Paragraphs.Add(ftrTable);

Aspose.Pdf.Heading heading = new Aspose.Pdf.Heading(1);
heading.IsInList = false;
heading.Text = “Supplier Name”;
heading.TextState.FontSize = 20;
heading.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);

page.Paragraphs.Add(heading);
page.Paragraphs[0].Margin = new MarginInfo(0, 10, 0, 0);

TextFragment textFragment = new TextFragment(“Services provided between dd/mm/yyyy and dd/mm/yyyy.”);

textFragment.TextState.Font = FontRepository.FindFont(“TimesNewRoman”);
textFragment.TextState.FontSize = 12;
textFragment.TextState.FontStyle = FontStyles.Italic;
textFragment.TextState.FormattingOptions = new TextFormattingOptions();

textFragment.TextState.FormattingOptions.LineSpacing = TextFormattingOptions.LineSpacingMode.FullSize;

page.Paragraphs.Add(textFragment);
page.Paragraphs[1].Margin = new MarginInfo(0, 10, 0, 0);

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

table.Broken = TableBroken.Vertical;
table.CornerStyle = BorderCornerStyle.Round;

table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.DefaultCellTextState.Font = FontRepository.FindFont(“Arial”);
table.DefaultCellTextState.FontSize = 12;

table.DefaultCellPadding = new MarginInfo(5, 5, 5, 5);
table.RepeatingRowsCount = 1;
table.ColumnWidths = string.Format(“200 100 200 200 100”);

for (int row_count = 1; row_count <= 50; row_count++)
{
Aspose.Pdf.Row row = table.Rows.Add();

if (row_count == 1)
{
    row.DefaultCellTextState.FontSize = 14;
    row.DefaultCellTextState.FontStyle = FontStyles.Bold;

    row.Cells.Add("Name");
    row.Cells.Add("Age");
    row.Cells.Add("Position");
    row.Cells.Add("Car");
    row.Cells.Add("Reg. No.");

    row.Cells[1].Alignment = HorizontalAlignment.Center;
}
else
{
    string name = string.Empty;
    int age = 0;
    string position = string.Empty;
    string car = string.Empty;
    string regNo = string.Empty;

    switch (row_count % 3)
    {
        case 1:
            name = "Director One";
            age = 51;
            position = "Director";
            car = "Audi A6 S-Line Black Edition";
            regNo = "XX99 XXX";
            break;
        case 2:
            name = "Director Two";
            age = 49;
            position = "Director";
            car = "Audi A4 Avant S-Line";
            regNo = "XX99 XXX";
            break;
        default:
            name = "Employee One";
            age = 46;
            position = "Employee";
            car = "Audi A1 SE";
            regNo = "XX99 XXX";
            break;
    }

    row.Cells.Add(name);
    row.Cells.Add(age.ToString());
    row.Cells.Add(position);
    row.Cells.Add(car);
    row.Cells.Add(regNo);

    row.Cells[1].Alignment = HorizontalAlignment.Center;
}

}

page.Paragraphs.Add(table);

TextFragment endOfReport = new TextFragment("*** End of Report ***");

endOfReport.TextState.Font = FontRepository.FindFont(“TimesNewRoman”);
endOfReport.TextState.FontSize = 12;
endOfReport.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
endOfReport.Margin = new MarginInfo(0, 0, 0, 10);

page.Paragraphs.Add(endOfReport);

doc.Save(".\Output.pdf");
`
I have uploaded the bitmap used as the logo and the sample output PDF in the attached zip.

Upload.zip (208.0 KB)

@MaccShaun,

We have created an output PDF with your code example. Please elaborate a bit more about the requirement and let us know the expected page order based on this output PDF document: Output.pdf (183.4 KB). We will investigate your scenario and share our findings with you.

Thank you,

Using the output file generated, the desired page ordering would be 1, 3, 2, 4.

@MaccShaun,

We have logged a feature request under the ticket ID PDFNET-44270 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.