Hi,
If you use HTML to PDF, you would do something like this:
Code: C#
//Load the existing document
PdfDocument doc = new PdfDocument(your_existing_pdf);
//Start from page 0, this output to the existing page
//instead of adding new pages
HtmlToPdf.Options.StartPageIndex = 0;
//Output HTML to the existing PDF file
HtmlToPdf.ConvertUrl(url, doc);
The above code will use all the existing page in your PDF file, and then add new pages. So for example, if your background PDF file is 1 page and your HTML output is 3 pages, then the first page will have background, and the second and the third won't. If you wish it to have background page in all three pages, you can follow these steps:
1. Run the conversion once to get the total page number:
Code: C#
//Get the total page number for an HTML
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertUrl(url, doc);
int pageCount = doc.Pages.Count;
2. Duplicate your background PDF file to contain that many pages by using PdfDocument.Merge
Code: C#
//Create a single PDF file with the same page repeating pageCount times
PdfDocument[] docs = new pdfDocument[pageCount];
for (int i = 0; i < pageCount; i++)
{
docs[i] = new PdfDocument(your_existing_pdf_file);
}
PdfDocument result = PdfDocument.Merge(docs);
You can then run ConvertHtml again on the above result PdfDocument and have background on every page.
Hope this helps. Please let us know if you still have any more questions.
Thanks!