Support Concurrent Call to HTML to PDF Converter?

I am evaluating Aspose.HTML for its ability to convert HTML to PDF. I plan to wrap this functionality in a web API, allowing other applications to make RESTful calls for HTML-to-PDF conversion. I would like to confirm whether the library supports concurrent processing for multiple HTML-to-PDF conversions. Thank you.

Convert HTML to PDF – C# code and Online Converter (aspose.com)

@Sol_Lee

Yes, Aspose.HTML supports concurrent processing for HTML to PDF conversions. This means you can wrap the conversion functionality in a web API and handle multiple requests simultaneously without any issues. The library is designed to facilitate easy access to conversion methods, allowing you to convert HTML documents to various formats, including PDF, efficiently.

To implement this in your web API, you can utilize asynchronous programming techniques in C#. This will enable your API to process multiple conversion requests concurrently. Here’s a simple example of how you might set up a method to handle HTML to PDF conversion:

using Aspose.Html;
using Aspose.Html.Converters;

public async Task ConvertHtmlToPdfAsync(string htmlFilePath, string pdfOutputPath)
{
    // Load the HTML document
    using (var document = new HTMLDocument(htmlFilePath))
    {
        // Convert HTML to PDF
        await Task.Run(() => 
        {
            Converter.ConvertHTML(document, new PdfSaveOptions(), pdfOutputPath);
        });
    }
}

In this example, the ConvertHtmlToPdfAsync method loads an HTML document and converts it to PDF in a separate task, allowing for concurrent processing of multiple requests.

Feel free to reach out if you have any more questions or need further assistance!

1 Like