We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Footer on only Last Page

Hello Support

I think you misunderstood my issue. As i define in screenshot there is repeated border in continue table format.borders appears till data after that it shows blank lines.i require these border repeat till footer.like this:-

Thanks for your help.

but we still facing some issue data wise.

for your understanding we uploaded all running code on below link (as i am unable to upload 45MB file). which we are using to generate documents.
http://testonline200.exportcentral.com.au/AsposeSampleApp.zip

  1. If there is 40 total line items in repeated table , document generate with 2 pages and both pages have footer.but our requirement is first page footer show continue and second page should have footer. (output WithCountinued.pdf).

You can also generate same with my code by clicking on highlighted buttons.

  1. If there is 54 total line items in repeated table ,its work fine for me. first page have continued text in footer and second page have footer. (output WithCountinued.pdf)

you can also check the code for highlighted button:

Please help me out for this, why the same code generating differ differ results.

Hi

Can you please urgently reply to this issue. We have explained in detail to you this issue over last 4 weeks but to date we have not received a working option from you.

Hi,

Thanks for your inquiry.

Please note that there are max three types of headers/footers e.g. FooterFirst, FooterPrimary and FooterEven in a Section. Similarly, we have three types of header e.g. HeaderFirst, HeaderPrimary and HeaderEven. Here are a few details of these header/footer types:

Member Name Description
HeaderEven Header for even numbered pages.
HeaderPrimary Primary header, also used for odd numbered pages.
FooterEven Footer for even numbered pages.
FooterPrimary Primary footer, also used for odd numbered pages.
HeaderFirst Header for the first page of the section.
FooterFirst Footer for the first page of the section.

A Document may have multiple Sections. You need to wrap content of every footer of every Section in Document inside an IF field like this:

{ IF "{ PAGE }" = "{ NUMPAGES }" "true part" "false part" }

See my this post where sample code wraps just content of FooterPrimary of FirstSection inside IF field. You need to repeat this for every footer in your document.

Now, coming to the borders problem, it looks like your application can insert any number of rows dynamically. If you insert a new table row, you’ll notice vertical length of those borders increase. And if you remove any row(s), you’ll notice vertical length of those borders decrease. Because, those are table borders and not page borders.

Your application also generates empty table rows at the end that result in extra pages(s). The only way you can remove those extra pages is to delete those empty rows. And when you delete empty rows using the code mentioned in my this post, some of the empty rows from the end of previous page also got removed. Hence the problem of decrease in vertical length of those borders occurs.

You may be able to overcome this problem by implementing the following workflow:

Delete empty row(s) from the end of Document only if their Page is blank.

Identify start and end page nodes of a page (see LayoutCollector & LayoutEnumerator classes)

Convert every node between start and end nodes to string and check if it is empty or not.

If page content is empty, then delete row.

Hope, this helps.

Best regards,

Hi

Can you please elaborate on the below statement:

You may be able to overcome this problem by implementing the following workflow:

Delete empty row(s) from the end of Document only if their Page is blank.

Identify start and end page nodes of a page (see LayoutCollector & LayoutEnumerator classes)

Convert every node between start and end nodes to string and check if it is empty or not.

If page content is empty, then delete row.

Appreciate if you could provide some sample code to achieve the above. Please explain how the classes- (see LayoutCollector & LayoutEnumerator ) can be used by some example

Would appreciate if you could urgently repply.

Hi

Can you please provide a reply on the below. we have raised this issue for over 5 weeks now. Todate we have not received any satisfactory answer which works:

Hi

Can you please elaborate on the below statement:

You may be able to overcome this problem by implementing the following workflow:

Delete empty row(s) from the end of Document only if their Page is blank.

Identify start and end page nodes of a page (see LayoutCollector & LayoutEnumerator classes)

Convert every node between start and end nodes to string and check if it is empty or not.

If page content is empty, then delete row.

Appreciate if you could provide some sample code to achieve the above. Please explain how the classes- (see LayoutCollector & LayoutEnumerator ) can be used by some example

Hi,

Thanks for your inquiry. I believe, the only outstanding problem is removal of extra last page (while preserving the borders). Can you please provide a Word document where the following code does not work?

Document doc = new Document(MyDir + @"in.docx");
if (string.IsNullOrEmpty(doc.FirstSection.Body.LastParagraph.ToString(SaveFormat.Text).Trim()))
    doc.FirstSection.Body.LastParagraph.Remove();

int pageCount = doc.PageCount;
Table table = doc.FirstSection.Body.Tables[0];
foreach (Row row in table)
{
    if (string.IsNullOrEmpty(row.ToString(SaveFormat.Text).Trim()))
    {
        LayoutCollector collector = new LayoutCollector(doc);
        if (collector.GetEndPageIndex(doc.FirstSection.Body.LastParagraph) == pageCount)
        {
            row.RowFormat.ClearFormatting();
            foreach (Cell cell in row)
            {
                cell.FirstParagraph.ParagraphBreakFont.Size = 1;
            }
        }
        else
        {
            break;
        }
    }
}
doc.Save(MyDir + @"17.1.0.docx");
doc.Save(MyDir + @"17.1.0.pdf");

Best regards,

Hello Support

We have 2 types of Document :

  1. Templates With Page Borders

In this case the Codes provided by You works perfectly fine and removes the extra blank page .

  1. Templates With Table Borders

In this case the Extra blank page is removed but the Vertical lines of the table only shows for the rows in which the data is there .

We tried to overcome this issue by adding Dummy Blank rows to that the vertical lines is filled till the end of the TABLE BODY but this also failed.

Attached is the Template for this Document with Table Borders and Vertical lines in Table Also attached is the Output.

Below is the Code which we are using :

Code For vertical Line

collector = new LayoutCollector(doc);
int pagenumber = collector.GetStartPageIndex(table.LastRow.FirstCell.LastParagraph);
int nextpagenumber = pagenumber + 1;
Row lastrow = (Row)table.LastRow.Clone(true);
foreach (Cell cell in lastrow.Cells)
{
    cell.RemoveAllChildren();
    cell.EnsureMinimum();
}
while (pagenumber != nextpagenumber)
{
    table.Rows.Add(lastrow.Clone(true));
    collector = new LayoutCollector(doc);
    pagenumber = collector.GetStartPageIndex(table.LastRow.FirstCell.LastParagraph);
}
table.LastRow.Remove();

Code For Remove Extra Page

if (string.IsNullOrEmpty(doc.FirstSection.Body.LastParagraph.ToString(SaveFormat.Text).Trim()))
    doc.FirstSection.Body.LastParagraph.Remove();

int pageCount = doc.PageCount;
Table table1 = doc.FirstSection.Body.Tables[0];
foreach (Row row in table1)
{
    if (string.IsNullOrEmpty(row.ToString(SaveFormat.Text).Trim()))
    {
        LayoutCollector collector1 = new LayoutCollector(doc);
        string FQ = row.ToString(SaveFormat.Text).Trim();
        if (doc.FirstSection.Body.LastParagraph != null)
        {
            if (collector1.GetEndPageIndex(doc.FirstSection.Body.LastParagraph) == pageCount)
            {
                row.RowFormat.ClearFormatting();
                foreach (Cell cell in row)
                {
                    cell.FirstParagraph.ParagraphBreakFont.Size = 1;
                }
            }
        }
        else
        {
            break;
        }
    }
}

Please let us know what is the issue in this .

Regards

Hi

This issue is very serious now, as our client is very upset and we require to resolve it ASAP

Appreciate your quick response.

Manish

Hi,

Thanks for your inquiry. Please use the following code to fill page with dummy Rows until the vertical Table borders are displayed for whole page.

Document doc = new Document(MyDir + @"Commercial+Invoice_Grain.docx");
int pageCount = doc.PageCount;
Table table = doc.FirstSection.Body.Tables[0];
LayoutCollector collector = new LayoutCollector(doc);
while (collector.GetEndPageIndex(doc.FirstSection.Body.LastParagraph) < (pageCount + 1))
{
    collector = new LayoutCollector(doc);
    Row row = (Row)table.LastRow.Clone(true);
    foreach (Cell cell in row)
    {
        cell.RemoveAllChildren();
    }
    table.Rows.Add(row);
}
table.LastRow.Remove();
doc.UpdatePageLayout();
doc.Save(MyDir + @"17.1.0.pdf");

Hope, this helps.

Best regards,

Thanks for this Code. This Helped us a lot . Initially it looks like the issue is resolved to some extent.

However we are checking this with various scenarios , data and templates. I will confirm this in next 2 days