Issue when I creating a Table in an existing pdf, when table breack to the new page creating dosent print the Header correctly

This issue print the PDF document whit all the new page creating by the Table breack without a Header.
Please any help with that will be helpfully.

Aspose.Pdf.Table table = new Aspose.Pdf.Table();
DataTable dt = queryTableAccount.ToDataTable();
foreach (DataColumn column in dt.Columns)
{
column.Caption = column.ColumnName.Replace("_", " ");
}

        // Set column widths of the table
        table.ColumnWidths = "100 100 100 50 100 100 100 100 100 100";
        table.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;
        // Set the table border color as Black
        table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .10f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
        // Set the border for table cells
        table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .10f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
        table.ImportDataTable(dt, true, 0, 0, queryTableAccount.Count(), 10);

        var templateStream = await _fileSystem.GetBlobStream(contractxsltTemplate);
        MemoryStream stream = new MemoryStream();

        //Create the PDF form the template with the Contract Data
        stream = PDFHelper.TransformPDF(templateStream, xDocument);
        Aspose.Pdf.Document doc = new Aspose.Pdf.Document(stream);

        PageInfo pageInfo = doc.PageInfo;
        Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

        marginInfo.Left = 30;
        marginInfo.Right = 30;
        marginInfo.Top = 343;
        marginInfo.Bottom = 77;
        table.HorizontalAlignment = HorizontalAlignment.Center;
        table.DefaultCellTextState.FontSize = 7;
        table.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        table.DefaultCellPadding = new MarginInfo(10, 5, 8, 5);

        //Add Loop for a New page Breack
        for (int i = 0; i < queryTableAccount.Count(); i++)
            {
                Row row = table.Rows.Add();
                if (i % 10 == 0 && i != 0)
                {
                    row.IsInNewPage = true;
                }
            }


        doc.Pages[2].Paragraphs.Add(table);

        PageCollection pageCollection = doc.Pages;
        // Get particular page
        Aspose.Pdf.Page pdfPage = pageCollection[1];
        //Get page height and width information
        var pageWidth = pdfPage.GetPageRect(true).Width;
        var pageHeight = pdfPage.GetPageRect(true).Height;

        // Setting page Size
        foreach (var itemPage in pageCollection)
        {
            if (itemPage.GetPageRect(true).Width != pageWidth && itemPage.GetPageRect(true).Height != pageHeight)
            {
                pdfPage.SetPageSize(pageWidth, pageHeight);
            }
        }
                    

        streamAspose.Seek(0, SeekOrigin.Begin);
        doc.Save(streamAspose, Aspose.Pdf.SaveFormat.Pdf);

@raulIfalashe2023

In order to understand the issue better, can you please share the sample generated output through above code snippet along with the expected output PDF? We will test the case in our environment and address it accordingly.

20230924071259379_Large Commercial Sales Agreement CSA 2023-Updated.pdf (463,4 KB)

Here is the example of the output pdf using in the sniped code posted before. In the page 2 the table is created fine, the problem is when the table are printing in the page 3, the breack cath anothe table in the page 2, as i will show you in the picture before.

Captura3-3.PNG (16,0 KB)
In this case dont show the ImageStamp added for the Header, only in the new page.

CapturaPage3-1.PNG (22,4 KB)
Here the new breack page was created with the other field, i will like to show only the continuos rows of the table

Here is the Template example where the Table most be added in the page 2
Template Example_Large Commercial Sales Agreement CSA 2023-Updated.pdf (445,2 KB)

@raulIfalashe2023

We are checking it and will get back to you shortly.

Hello, any answer or help for the Issue mentioned.

@raulIfalashe2023

In order to repeat the table headers on the subsequent pages, you need to use Table.RepeatingRowsCount property. We have noticed that you are not using this property in your code snippet. Please try to use it along with the latest version of the API and feel free to let us know in case you still face any issues.

Ok Sr thanks, and what can I do with the other issue, i need to create the new breack page only with the table continue rows, and is created, with othe component like the first page

@raulIfalashe2023

As per our understandings, you have two requirements:

1- Show table headers after page break if table is lengthy
2- Do not show table headers after page break

Can you please confirm if our understandings are correct? Can you please share a sample console application that can reproduce the issue that you are facing so that we can better understand it and share our feedback with you accordingly?

public class InsertPageBreak
{
public static void Run()
{
// ExStart:InsertPageBreak
// The path to the documents directory.
string dataDir = @“E:\Propeller\Tickets\138533\Aspose Ejemplos Tabla\Aspose.PDF-for-.NET-master\Aspose.PDF-for-.NET-master\Examples\Data\AsposePDF\Tables\Large Commercial Sales Agreement CSA 2023-Updated.pdf”;
string dataDirImag = RunExamples.GetDataDir_AsposePdf_StampsWatermarks();

        // Instantiate Document instance
        Document doc = new Document(dataDir);
        // Add page to pages collection of PDF file
        //doc.Pages.Add();
        

        // Create table instance
        Aspose.Pdf.Table tab = new Aspose.Pdf.Table();
        // Set border style for table
        tab.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
        // Set default border style for table with border color as Red
        tab.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
        // Specify table columsn widht
        tab.ColumnWidths = "100 100";
        // Create a loop to add 200 rows for table
        for (int counter = 0; counter <= 30; counter++)
        {
            Aspose.Pdf.Row row = new Aspose.Pdf.Row();
            tab.Rows.Add(row);
            Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();
            cell1.Paragraphs.Add(new TextFragment("Cell " + counter + ", 0"));
            row.Cells.Add(cell1); Aspose.Pdf.Cell cell2 = new Aspose.Pdf.Cell();
            cell2.Paragraphs.Add(new TextFragment("Cell " + counter + ", 1"));
            row.Cells.Add(cell2);
            // When 10 rows are added, render new row in new page
            if (counter % 10 == 0 && counter != 0) row.IsInNewPage = true;
        }
        tab.RepeatingRowsCount = 1;
        // Add table to paragraphs collection of PDF file
        doc.Pages[1].Paragraphs.Add(tab);
        //PageCollection pageCollection = doc.Pages;
        ImageStamp imageStamp = new ImageStamp(dataDirImag + "Summer.jpg");

        // Set properties of the stamp
        imageStamp.TopMargin = 5;
        imageStamp.HorizontalAlignment = HorizontalAlignment.Left;
        imageStamp.VerticalAlignment = VerticalAlignment.Top;

        HeaderFooter header = new HeaderFooter();
        TextFragment text = new TextFragment("Summer Energy, LLC");            
        TextFragment text1 = new TextFragment("PUCT #10205");
        TextFragment text2 = new TextFragment("Version #SE42023");
        
        header.Paragraphs.Add(text);
        header.Paragraphs.Add(text1);
        header.Paragraphs.Add(text2);
        foreach (var item in header.Paragraphs)
        {
            item.HorizontalAlignment = HorizontalAlignment.Right;                
        }
        header.Margin.Left = 425;
        header.Margin.Top = 40;

        PageInfo pageInfo = doc.PageInfo;
        Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;



        marginInfo.Left = 30;
        marginInfo.Right = 30;
        marginInfo.Top = 320;
        marginInfo.Bottom = 77;

        // Add header on all pages
        foreach (Page page in doc.Pages)
        {
            page.AddStamp(imageStamp);
            page.Header = header;
        }
        dataDir = dataDir + "_out.pdf";
        // Save the PDF document
        doc.Save(dataDir);
        // ExEnd:InsertPageBreak
        // Add header on all pages
        

        //doc.Save(dataDir);
        Console.WriteLine("\nPage break inserted successfully.\nFile saved at " + dataDir);
        
    }
}

Here is a sniped code.

Large Commercial Sales Agreement CSA 2023-Updated.pdf (94,5 KB)
This is the template PDf when i going to insert the table

Large Commercial Sales Agreement CSA 2023-Updated.pdf_out.pdf (148,6 KB)

This is the output pdf with the table

What i need is show only the table in the new page afte the breack row

imagen_2023-10-12_222752959.png (24,0 KB)

I need delete the yelow marcked element in the new page breack, how can i do that ??

@raulIfalashe2023

We are checking it and will get back to you shortly.

@raulIfalashe2023

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55780

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.