Free Support Forum -

Incorrect HTML to PDF conversion result using Java API compared to the online HTML to PDF conversion

Tried to convert the HTML file included here: (1.5 KB) using the following Java code:

public StreamingResponseBody asposePdf(@RequestParam(name="html") final String htmlInput) throws Exception {
    final var license = new com.aspose.html.License();
    final var pdfSaveOptions = new com.aspose.html.saving.PdfSaveOptions();
    final var document = new com.aspose.html.HTMLDocument(htmlInput, ".");
    try {
        final var out = new ByteArrayOutputStream();
        final var device = new com.aspose.html.rendering.pdf.PdfDevice(pdfSaveOptions, out);
        return streamResponse(out.toByteArray());
    } finally {

and the result is different (wrong alignment and formatting, table does not render) compared to the same input begin used in:

Any idea why this happens ?

I am using a temporary license for Aspose.HTML with Aspose Java v 21.4 running on a Spring Boot 2.4.4 application.

For comparison
Online tool result: test_aspose.pdf (67.1 KB)
Java API result: response.pdf (80.1 KB)


We would like to share with you that Aspose.HTML for .NET has been implemented behind the online utility of HTML to PDF conversion. We are in process to port all .NET features and improvement in Java version of the API and as soon as it is done, the results of conversion will be better.

We have further log a ticket as HTMLJAVA-803 in our issue tracking system for this case. We will look into its details and let you know as soon as it is fixed. Please be patient and spare us some time.

We apologize for the inconvenience.