Graph Line in all pages displaying only on first 2 pages

Hi there,

I have a table that spam over multiple pages and I want to print/stamp a horizontal line at the bottom of each page.
Using the code below I’m able to see the line only on the first two pages, no matter which size/position I use for the Aspose.Pdf.Drawing.Line or the Aspose.Pdf.Drawing.Graph.

Is there anything that I’m doing wrong here?
This is the output PDF TestLine.pdf (24.6 KB)

And this is my code:

        Document document = new Document();
        Page page = document.Pages.Add();
        page.PageInfo.Margin = defaultPageMargins;

        Aspose.Pdf.Table table = new Aspose.Pdf.Table();
        table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, .1f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
        table.HorizontalAlignment = HorizontalAlignment.Center;

        table.ColumnWidths = "45 50 50 40 90 90 55 55 55";
        table.DefaultCellTextState.FontSize = 8;

        Row headerRow = table.Rows.Add();
        headerRow.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, 1f, Aspose.Pdf.Color.Parse("#004307"));
        headerRow.DefaultCellTextState.FontStyle = FontStyles.Bold;
        headerRow.DefaultCellPadding = defaultCellPadding;

        headerRow.Cells.Add("Col A");
        headerRow.Cells.Add("Col B");
        headerRow.Cells.Add("Col C");
        headerRow.Cells.Add("Type").Alignment = HorizontalAlignment.Center;
        headerRow.Cells.Add("Desc");
        headerRow.Cells.Add("Description");
        headerRow.Cells.Add("FF").Alignment = HorizontalAlignment.Right;
        headerRow.Cells.Add("LL").Alignment = HorizontalAlignment.Right;
        headerRow.Cells.Add("BB").Alignment = HorizontalAlignment.Right;

        for (int row_count = 0; row_count < 120; row_count++)
        {
            // Add row to table
            Aspose.Pdf.Row row = table.Rows.Add();
            row.DefaultCellPadding = defaultCellPadding;

            // Add table cells
            row.Cells.Add("XYZ");
            row.Cells.Add("dasdasd adsasasd as");
            row.Cells.Add("01/01/2021");
            row.Cells.Add("LX").Alignment = HorizontalAlignment.Center;
            row.Cells.Add("desription");
            row.Cells.Add("Another Desription");
            row.Cells.Add((12312).ToString("N2", CultureInfo.CurrentCulture)).Alignment = HorizontalAlignment.Right;
            row.Cells.Add((12312).ToString("N2", CultureInfo.CurrentCulture)).Alignment = HorizontalAlignment.Right;
            row.Cells.Add("435").Alignment = HorizontalAlignment.Right;

        }

        page.Paragraphs.Add(table);
        logger.LogDebug($"Number pages in the doc: {document.Pages.Count}");
        document.ProcessParagraphs();
        logger.LogDebug($"Number pages in the doc after save: {document.Pages.Count}");

        for (int i = 1; i <= document.Pages.Count; i++)
        //foreach (var p in document.Pages)
        {
            var p = document.Pages[i];
            logger.LogDebug(p.Number.ToString());
            logger.LogDebug($"Page Info - PW={p.PageInfo.Width} PH={p.PageInfo.Height} PLLX={p.Rect.LLX} PLLY={p.Rect.LLY} PURX={p.Rect.URX} PURY={p.Rect.URY}");
            logger.LogDebug($"Page Margin - MB={p.PageInfo.Margin.Bottom} MT={p.PageInfo.Margin.Top} ML={p.PageInfo.Margin.Left} MR={p.PageInfo.Margin.Right}");

            var lineHeight = (float)(p.Rect.Height - p.PageInfo.Margin.Bottom - p.PageInfo.Margin.Top);
            var lineWidth = (float)(p.PageInfo.Width - p.PageInfo.Margin.Left - p.PageInfo.Margin.Right);
            var marginTBTotal = (float)(p.PageInfo.Margin.Left + p.PageInfo.Margin.Right);
            logger.LogDebug($"Calculated line size/position lineHeight={lineHeight} lineWidth={lineWidth}");

            Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph((float)p.PageInfo.Width, (float)p.Rect.Height);
            graph.Top = 0;
            graph.Left = 0;
            Aspose.Pdf.Drawing.Line line = new Aspose.Pdf.Drawing.Line(new float[] { 0, marginTBTotal, lineWidth, marginTBTotal });
            line.GraphInfo.Color = _appColor;
            graph.Shapes.Add(line);
            p.Paragraphs.Add(graph);
        }

        using (Stream outputStream = new FileStream(_dataDir + "TestLine.pdf", FileMode.Create, FileAccess.Write))
        {
            document.Save(outputStream);
            document.Dispose();
        }

This is the output of the iteration over the pages:

1
Page Info - PW=595 PH=842 PLLX=0 PLLY=0 PURX=595 PURY=842
Page Margin - MB=40 MT=40 ML=30 MR=30
Calculated line size/position lineHeight=762 lineWidth=535
2
Page Info - PW=595 PH=842 PLLX=0 PLLY=0 PURX=595 PURY=842
Page Margin - MB=40 MT=40 ML=30 MR=30
Calculated line size/position lineHeight=762 lineWidth=535
3
Page Info - PW=595 PH=842 PLLX=0 PLLY=0 PURX=595 PURY=842
Page Margin - MB=40 MT=40 ML=30 MR=30
Calculated line size/position lineHeight=762 lineWidth=535
4
Page Info - PW=595 PH=842 PLLX=0 PLLY=0 PURX=595 PURY=842
Page Margin - MB=40 MT=40 ML=30 MR=30
Calculated line size/position lineHeight=762 lineWidth=535

@Middiu

Can you please share the value of defaultPageMargins so that we can test the shared code snippet at our end to generate the similar PDF output and share our feedback with you accordingly.

Hello, this is the definition:

private static readonly MarginInfo defaultPageMargins = new MarginInfo(30, 40, 30, 40);

Thanks

@Middiu

We were able to generate the similar output in our environment and have also noticed that API was unable to add line on every page of the PDF strangely. The code seems fine and this should not happen. For further investigation, we have logged a ticket in our issue tracking system under the ID PDFNET-50261. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks for the info.

Also, not sure if you noticed that in the first two pages the line is positioned at a different high.

Regards

@Middiu

Can you please elaborate a bit more on the different height of the line so that we can address it as well? Do you mean that the line should be added at lower position than it is being added now?

If you notice the pdf produced, in the first two pages the line is printed, but it’s on a different position, when it should be at the same on all the pages.

The difference is not big, but if you pay attention you can see it.

@Middiu

We have logged this information along with the ticket as well and will include it in investigation process also. We will inform you once we have additional updates in this regard.

hello, any update on this? has this issue been resolved yet?

@Middiu

We regret to inform you that the logged ticket could not get resolved due to other issues in the queue logged prior to it. However, we have recorded your concerns and will let you know as soon as we make some definite progress towards ticket resolution. Please spare us some time.

We apologize for the inconvenience.