EVO HTML to PDF Converter

Merge Multiple HTML Pages into a Single PDF

EVO PDF Client for .NET Documentation

EVO HTML to PDF Converter allows you to add multiple HTML documents into a single PDF document. You can start with an empty PDF document represented by a Document object and then for each HTML document you add a HtmlToPdfElement object to the PDF document. A HTML to PDF element can be added where the previous element ended or it can be added to a new PDF page.

Code Sample - Merge Multiple HTML Pages into a Single PDF

C#
protected void convertToPdf()
{
    // Get the server IP and port
    String serverIP = textBoxServerIP.Text;
    uint serverPort = uint.Parse(textBoxServerPort.Text);

    // Create the PDF document where to add the HTML documents
    Document pdfDocument = null;
    if (radioButtonUseTcpService.Checked)
        pdfDocument = new Document(serverIP, serverPort);
    else
        pdfDocument = new Document(true, textBoxWebServiceUrl.Text);

    // Set optional service password
    if (textBoxServicePassword.Text.Length > 0)
        pdfDocument.ServicePassword = textBoxServicePassword.Text;

    // Set license key received after purchase to use the converter in licensed mode
    // Leave it not set to use the converter in demo mode
    pdfDocument.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";

    // Create a PDF page where to add the first HTML
    PdfPage firstPdfPage = pdfDocument.AddPage();

    // Create the first HTML to PDF element
    HtmlToPdfElement firstHtml = new HtmlToPdfElement(0, 0, firstUrlTextBox.Text);

    // Optionally set a delay before conversion to allow asynchronous scripts to finish
    firstHtml.ConversionDelay = 2;

    // Add the first HTML to PDF document
    firstPdfPage.AddElement(firstHtml);

    PdfPage secondPdfPage = null;

    // Create the second HTML to PDF element
    HtmlToPdfElement secondHtml = new HtmlToPdfElement(0, 0, secondUrlTextBox.Text);

    // Optionally set a delay before conversion to allow asynchronous scripts to finish
    secondHtml.ConversionDelay = 2;

    if (startNewPageCheckBox.Checked)
    {
        // Create a PDF page where to add the second HTML
        secondPdfPage = pdfDocument.AddPage();

        // Add the second HTML to PDF document
        secondPdfPage.AddElement(secondHtml);
    }
    else
    {
        // Add the second HTML right after the first one
        pdfDocument.AddElement(secondHtml);
    }

    // Save the PDF document in a memory buffer
    byte[] outPdfBuffer = pdfDocument.Save();
}
See Also

Other Resources