Time delay while adding HTML Header and footer for pdf pages .Net

Hi,
I m converting Html to PDF using Aspose PDF .Net. In this process, I want to add HTML to header & Footer. For this, I m looping through all the pages and by using HTML Fragment assigning the HTML content to the “page.Header”. It is working as expected but taking too much time to save the document to memory stream. Below is the pseudo code for the same.

Pseudo code:
var ms = new MemoryStream();

Document doc = new Document(ms, new HtmlLoadOptions());//This also takes around 1 min

foreach (Page page in doc.Pages)//We have around 60 pages
{
Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();

HtmlFragment htmlFrag = new HtmlFragment(“

Some more html tags with breaks
”);

//Some code to set appropriate position for header /footer

header.Paragraphs.Add(htmlFrag);

page.Header = header;
}
doc.Save(ms, Aspose.Pdf.SaveFormat.Pdf);//Taking too much time for saving (around 2 mins)

Thanks,
Ajay Kumar

@agangula

Thank for contacting support.

Please note the performance of the API depends upon many factors to be noticed i.e version of the API, environment in which you are using API, structure and complexity of the input document and content which you are adding into document. We will really appreciate if you can please share the source HTML file and HTML string (you are adding inside header), so that we can test the scenario in our environment and address it accordingly.