We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception thrown out when converting Html to PDF

Using free trial license.
The following exception is thrown out when converting html to pdf -
max(48750) < opt(97500)

HTML to convert -

P { margin-top: 0; margin-bottom: 0; }
<div dir="ltr">
    
    <div style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
        <center style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; width:100%; background:#ffffff; margin:0">
            
            <div class="x_x_email-container" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; max-width:600px; margin:0">
                <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; border-spacing:0px!important; border-collapse:collapse!important; table-layout:fixed!important; margin:0px auto!important; max-width:600px; margin:0 auto">
                    <tbody style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                        
                        <tr style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                            <td style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; text-align:center">
                                <div class="x_x_stack-column" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; display:inline-block; max-width:100%; vertical-align:top; width:100%">
                                    <table role="presentation" aria-hidden="true" border="0" cellpadding="0" cellspacing="0" align="center" width="95%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; border-spacing:0px!important; border-collapse:collapse!important; table-layout:fixed!important; margin:0px auto!important; max-width:570px">
                                        <tbody style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                            
                                            <tr style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                <td align="center" height="100%" valign="top" width="100%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; padding-top:10px">
                                                    <table role="presentation" aria-hidden="true" border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; border-spacing:0px!important; border-collapse:collapse!important; table-layout:fixed!important; margin:0px auto!important; table-layout:auto; max-width:570px; border:1.25px solid #cccccc">
                                                        <tbody style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                            <tr style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                                <td align="center" height="100%" valign="top" width="100%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                                    <table role="presentation" aria-hidden="true" border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; border-spacing:0px!important; border-collapse:collapse!important; table-layout:fixed!important; margin:0px auto!important; table-layout:auto; table-layout:auto; max-width:570px">
                                                                        <tbody style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                                            <tr style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important">
                                                                                <td align="left" valign="top" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; padding:15px">
                                                                                    <div class="x_x_item-img-column" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; display:inline-block; max-width:100px; min-width:100px; vertical-align:top; width:100%; padding-right:30px">
                                                                                        
                                                                                    </div>
                                                                                    <div class="x_x_item-desc-column" style="font-weight:normal; color:rgb(51,51,51); font-size:16px; line-height:24px; font-family:&quot;Helvetica Neue&quot;,Helvetica,Roboto,Arial,sans-serif!important; display:inline-block; max-width:50%; min-width:20%; vertical-align:top; width:100%">
                                                                                        
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                           
                                                            
                                                            
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                       
                    </tbody>
                </table>
            </div>
        </center>
    </div>
</div>

The C# code to do conversion -
public void HtmlToPdf(string htmlFilePath)
{
using (var htmlStream = new MemoryStream(File.ReadAllBytes(htmlFilePath)))
using (var pdfStream = new MemoryStream())
{
var options = new Aspose.Pdf.HtmlLoadOptions();

            var pdfDocument = new Aspose.Pdf.Document(htmlStream, options);

            pdfDocument.Save(pdfStream);

            File.WriteAllBytes(htmlFilePath.Replace(".htm", ".aspose.pdf"), pdfStream.ToArray());
        }
    }

@cgong2018

Thanks for contacting support.

We were able to replicate the issue in our environment using Aspose.PDF for .NET 18.12 and logged it as PDFNET-45858 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.