[Urgent] Different footer section for multiple page document

I need to generate different set of footer in my multi page pdf document which is generated using Aspose.Pdf.Generator

I am dynamically generating the pdf and the data I am adding to the section is spannign across multiple pages.

I need a separate footer for the last page only and separate footer for the rest of the pages, starting from the first page to the last-1 page.

Here is the code snippet I am using to generate the footer:

Sections sections = request.Pdf.Sections;

int secCount = sections.Count;

Section sec1 = request.Pdf.Sections[sections.Count - 1];

sec1.SetPageSettings();

// Create a Footer Section of the document

Aspose.Pdf.Generator.HeaderFooter footer1 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

footer1.IsLastPageOnly = false;

// set the Odd footer of the PDF file

sec1.OddFooter = footer1;

// set the Even footer of the PDF file

sec1.EvenFooter = footer1;

// Footer content display

FooterContentForAllPages(footer1);

Aspose.Pdf.Generator.HeaderFooter footer2 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

// set the Odd footer of the PDF file

sec1.AdditionalOddFooter = footer2;

// set the Even footer of the PDF file

sec1.AdditionalEvenFooter = footer2;

footer2.IsLastPageOnly = true;

// Footer content display

FooterContentForLastPage(footer2);

When we generate more than one page document using this, footer1 is getting displayed in all the pages. althought footer2 is getting displayed only in the last page. I want to display footer1 on all pages except the last page.

Please provide a solution for this.

Thanks,

Saikat

Hi Saikat,


Thanks for your inquiry. We are looking into your requirements. I’ve logged your request in our issue tracking system as PDFNEWNET-35177 for further investigation and resolution. We will update you via this forum thread as soon as it is resolved.

Sorry for the inconvenience faced.

Best Regards.

Hi Saikat,


Thanks for your patience.

I have further discussed with development team and in order to resolve this problem, we will have to introduce some new methods to fulfill this requirement. Furthermore, as per our current estimates, we can get this problem resolved in next version of Aspose.Pdf fro .NET 8.0.0 which is planned to release in May-2013. However if you require some immediate resolution, you may consider opting Enterprise Support or Priority Support models and the development team can look over this issue on priority basis and can prepare a hotfix.

Thanks for your patience and comprehension in this regard.

Hi Saikat,


Thanks for your patience.

In order to have different footer on last page of PDF file, please try using the following code snippet. For your reference, I have also attached the sample output PDF file.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

Aspose.Pdf.HeaderFooter hf1 = new Aspose.Pdf.HeaderFooter();

TextFragment text = new TextFragment("Page Footer");

hf1.Paragraphs.Add(text);

page.Footer = hf1;

//Instantiate a table object

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

//Add the table in paragraphs collection of the desired section

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "100 100";

page.OnCustomizeHeaderFooter += CustomizeHeaderFooter;

//Create rows in the table and then cells in the rows

for (int i = 0; i < 500; i++)

{

Aspose.Pdf.Row row = tab1.Rows.Add();

for (int c = 0; c < 2; c++)

{

Aspose.Pdf.Cell c1 = row.Cells.Add("item1" + c);

c1.Margin = new Aspose.Pdf.MarginInfo();

c1.Margin.Left = 30;

}

}

doc.Save("c:/pdftest/DifferenceFooter.pdf");

public void CustomizeHeaderFooter(ref Aspose.Pdf.HeaderFooter header, ref Aspose.Pdf.HeaderFooter footer, int pageNum)

{

if (pageNum == 10)

{

footer = new Aspose.Pdf.HeaderFooter();

TextFragment text1 = new TextFragment("Last Page Footer");

footer.Paragraphs.Add(text1);

}

}

The issues you have found earlier (filed as PDFNEWNET-35177) have been fixed in Aspose.Pdf for .NET 8.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Thanks for working on this bug. I was looking at the implenentation you suggested, have some queries regarding it.

I am not using Document object for creating the pdf. I am using Aspose.pdf.Generator to create the pdf. Does your solution works for the same. If yes, can you please help me with the implementation.

If it does not work with Pdf.Generator , then I cannot say that my issue has been resolved.

Thanks.

Hi,
I have seen your implementation with page and document objects. However I am not using Document object for creating the pdf. I am using Aspose.pdf.Generator to create the pdf. I have downloaded Aspose.net 8.0 dlls, can you please help me implementing different footer section for multiple page with Aspose.pdf generator..

This is urgent requirement in my project , requesting swift reply.

Thanks

Hi there,


Thanks for your feedback. We are looking into your requirement and will update you via this forum thread about the issue progress.

However, we will recommend you to use above shared solution as it uses new DOM approach, that is good in performance and results than Apose.Pdf.Generator.

Sorry for the inconvenience faced.

Best Regards,

Hi there,


Thanks for your patience. I’ve discussed your concern with the development team and want to update you that Aspose.Pdf.Generator is going to obsolete now as we are working over new DOM approach. Unfortunately we are not doing any enhancement in Aspose.Pdf.Generator so I’m afraid you have to use above suggested solution for your requirements.

Please feel free to contact us for any further assistance.

Best Regards,

Hi,


I am facing the same issue of showing different footer in last page when generating pdf. I am also using Aspose.Pdf.Generator. I would like to know if this won’t be supported in Aspose.Pdf.Generator? If I have to change to use the new DOM approach to generate the pdf, are all the methods in Aspose.Pdf.Generator supported in the new DOM approach? For example, how to add html to document?

Thanks,
Iris

Hi Iris,


Thanks for contacting support.

As shared above, I am afraid we are not fixing any problems or introducing new features/enhancements Aspose.Pdf.Generator namespace and most of the new development is being made in Aspose.Pdf namespace. Therefore it’s highly recommended to migrate your code to new Document Object Model of Aspose.Pdf namespace. In order to generate different footer on last page, please try using the code snippet suggested over 466088.

Furthermore, please note that most of the features of Aspose.Pdf.Generator are supported in Aspose.Pdf namespace and in case you still face any issue, please share the code snippet so that we can test the scenario at our end. We are sorry for any inconvenience.
Hi Iris,

IrisWu:
Hi,

If I have to change to use the new DOM approach to generate the pdf, are all the methods in Aspose.Pdf.Generator supported in the new DOM approach? For example, how to add html to document?


In addition to Nayyer reply, I would like to update you that currently Aspose.Pdf.Document(DOM approach) renders HTML document to PDF document but it doesn't support to include HTML contents in PDF document at the moment. We've already logged this feature request as PDFNEWNET-35804 in our issue tracking system. We will update you via this forum thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,