Merging multiple PDFs to single PDF (PDFs generated from HTML)

I want to merge two documents which has Header and footer to a single pdf. Below is giving me pdfs with out header and footer and different page sizes.

PDFs are generated with html. can you let me know what is the issue with below code. ?

HtmlLoadOptions options = new HtmlLoadOptions();
options.PageInfo.Margin = new MarginInfo { Left = 15, Right = 15, Top = 150, Bottom = 15 };
options.PageInfo.Width = 1000;
options.PageInfo.Height = 800;

// Instantiate Document object
byte[] byteArray = Encoding.UTF8.GetBytes("Body of html page1



endbody");
MemoryStream stream = new MemoryStream(byteArray);
Document pdfDocument1 = new Document(stream, options);
pdfDocument1.ProcessParagraphs();

// Open the second document
byte[] byteArray2 = Encoding.UTF8.GetBytes("Body of html page2



endbody");
Document pdfDocument2 = new Document(new MemoryStream(byteArray2), options);
pdfDocument2.PageMode = Aspose.Pdf.DOM.PageMode.FullScreen;
pdfDocument2.ProcessParagraphs();

Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();

var reportHeader = "

Test Header

";
Aspose.Pdf.HtmlFragment hh = new HtmlFragment(reportHeader);
header.Paragraphs.Add(hh);

var reportFooter = "This is footer";
Aspose.Pdf.HtmlFragment ff = new HtmlFragment(reportFooter);
footer.Paragraphs.Add(ff);

foreach (Page page in pdfDocument1.Pages)
{
page.Header = header;
page.Footer = footer;
}
foreach (Page page in pdfDocument2.Pages)
{
page.Header = header;
page.Footer = footer;
}
// Save PDF file
pdfDocument1.Pages.Add(pdfDocument2.Pages);
pdfDocument1.Save(myDir + "htmltopdf.pdf");

Hi Raju,


Thanks
for using our API’s.<o:p></o:p>

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-38888. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.