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

Free Support Forum - aspose.com

Add Table along with Bullets inside PDF with HTML using Aspose.PDF for .NET

HI Team,

We are using ASPOSE version 19.10.0, we found a scenario in which ASPOSE if failing to generate PDF report. We got this two data for two diffrent HTML fragements, Failing the ASPOSE to Create Report. In Code we are Adding Font tag for these data before adding into HtmlFragment.

Please check below code and let me know what is missing?

        Data 1 = "<p><br></p><table><tbody><tr height="160" style="height: 120pt;"><td height="160" class="xl65" width="587" style="height: 120pt; width: 440pt;">I89B - R10.2.0 Door on Room Temperature Sample Storage, B-245, had sign with storage temperature requirement as “USP Controlled Room Temperature (CRT), between 15-25°C”. This&nbsp; &nbsp;requirement is not fully aligned with definition of USP CRT. It was initially explained as ELLI's interpretation of USP storage requirements and later clarified as “derived” from USP CRT.&nbsp;<br><br><font class="font5">Recommendation:&nbsp;</font><font class="font0">Change sign to “Storage Temperature between 15-25°C (derived from USP CRT)”s I89B - R10.2.0</font></td></tr></tbody></table><p><br></p>";
        Data 2 = "<ul><li>TESt TEST</li></ul>"
        var columnWidth = "50% 50% ";
        var myTable = _reportHelperService.AddTable(true, columnWidth);
        _reportHelperService.AddHeaderRow(myTable, input.ReportMiscInfo, mySection)
        Row row = table.Rows.Add();
        Cell cell;
        // Add Data 1
         var htmlData1 = $"<font size=13>{Data1}</font>";
          var htmlFrgMent1 = new HtmlFragment(htmlData1) { TextState = new TextState(_font.FontName, isBold, isItalic) { FontSize = fontSize, Font = _font, Underline = isUnderlined } };
            htmlFrgMent.TextState.Font = _font;
            htmlFrgMent.TextState.FontSize = fontSize;
            htmlFrgMent.HorizontalAlignment = horizontalAlignment;
            htmlFrgMent.VerticalAlignment = verticalAlignment;
            cell = row.Cells.Add();
            cell.Paragraphs.Add(htmlFrgMent1);
          // Add Data 2
          var htmlData2 = $"<font size='13'>{Data2}</font>";
          var htmlFrgMent2 = new HtmlFragment(htmlData2) { TextState = new TextState(_font.FontName, isBold, isItalic) { FontSize = fontSize, Font = _font, Underline = isUnderlined } };
            htmlFrgMent.TextState.Font = _font;
            htmlFrgMent.TextState.FontSize = fontSize;
            htmlFrgMent.HorizontalAlignment = horizontalAlignment;
            htmlFrgMent.VerticalAlignment = verticalAlignment;
            cell = row.Cells.Add();
            cell.Paragraphs.Add(htmlFrgMent2);
           _page.Paragraphs.Add(myTable);

@aparnabn

We tested the scenario in our environment and found no issue. We tried to render final HTML string in a browser as .html and the result was similar to what was in generated PDF. For your kind reference, we have attached both HTML and PDF files.

htmltable.zip (618 Bytes)
outputPDF.pdf (52.4 KB)

Would you please try with correct HTML and in case you still face any rendering issue, please let us know.