Aspose HTML To PDF - spaces are not the same and NullReference error

Hello - I’m using Aspose.HTML to convert HTML to PDF, however, after trying to generate, there are some space that are not actually equal to the HTML output.
image.png (1.6 KB)

As you can see in the attached image, the space seems to shrink. Any idea how to fix this?

Additional question, is Aspose.HTML compatible w/ net core 2? I’m getting an error Nullreference w/ the renderer.Render(pdfDevice, document)… both parameters are not empty or null

The version I’m using is 24.8
image.png (1.57 KB)

1 Like

@kdepadua

Are you trying to convert HTML to PDF using our online free app, or are you using the stand-alone API?
image.png (1.57 KB)

@atir.tahir I’m using the API. Aspose.HTML version 24.8…

@kdepadua,

Could you please provide your HTML file (please zip it prior to attaching it here) or give us the source (HTML) code if you are preparing it on the fly?

Aspose.HTML is compatible with .NETStandard 2.0/.NET Core 2.0. Please refer to the System Requirements page for more information. Could you provide a sample application to demonstrate the issue?

Furthermore, I am transferring your thread to the appropriate forum where you will receive the necessary assistance accordingly.

Hi @amjad.sahi -

Here’s the sample HTML code for that part

<table class="proposal-estimate-grid">
                      <caption>
                        <div class="estimate-caption" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px; text-align: center; height: 37.8px;">Estimate Summary - Reimbursable</div>
                      </caption>
                      <thead>
                        <tr class="estimate-grid-header">
                          <td class="" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">Test Est</td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">Hours/Quantity</td>
                          <td class="" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">Estimated Cost</td>
                        </tr>
                      </thead>
                      <tbody class="placeholder-content">
                        <tr class="estimate-grid-body">
                          <td class="" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.Description">Labor</span>
                          </td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedHours"></span>
                          </td>
                          <td class="" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedCost"></span>
                          </td>
                        </tr>
                        <tr class="estimate-grid-body">
                          <td class="" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.Description">Consultants</span>
                          </td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedHours"></span>
                          </td>
                          <td class="" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedCost"></span>
                          </td>
                        </tr>
                        <tr class="estimate-grid-body">
                          <td class="" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.Description">Expenses</span>
                          </td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedHours"></span>
                          </td>
                          <td class="" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedCost"></span>
                          </td>
                        </tr>
                        <tr class="estimate-grid-body">
                          <td class="" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.Description">Units</span>
                          </td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedHours"></span>
                          </td>
                          <td class="" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(226, 244, 244); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="PRESTIMATESUMMARY.PlannedCost"></span>
                          </td>
                        </tr>
                      </tbody>
                      <tfoot>
                        <tr class="estimate-grid-footer">
                          <td class="align-right" data-column="Description" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;"></td>
                          <td class="align-right" data-column="HoursQuantity" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;"></td>
                          <td class="align-right" data-column="PlannedCost" style="padding: 5.74px 9.6px 3.86px; font-size: 11px; color: rgb(77, 77, 77); background-color: rgb(255, 255, 255); border-color: rgb(77, 77, 77); border-width: 1px;">
                            <span class="placeholder-field" data-fieldid="_TOTAL_PRESTIMATESUMMARY.PlannedCost"></span>
                          </td>
                        </tr>
                      </tfoot>
                    </table>

For the rendering, I’m using the following VB code

        Using document As New Aspose.Html.HTMLDocument(htmlContent, "")

            ' Initialize PdfDevice with the output stream
            Using pdfDevice As New Aspose.Html.Rendering.Pdf.PdfDevice(pdfOptions, pdfStream)
                ' Render the HTML document to PDF
                Dim renderer As New Aspose.Html.Rendering.HtmlRenderer()
                renderer.Render(pdfDevice, document)
            End Using
        End Using

@kdepadua

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-5808

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.