Text goes out of the right side boundary when converting a html string to pdf

I have a 30 days trial license of the Aspose.PDF for .Net. I am trying to convert a html string to PDF and the text in my pdf goes out of the right boundary. I have tried options like “page.PageInfo.Margin.Right” but still no luck. Below is my code

SetLicenseExample();
Document doc = new Document();
Page page = doc.Pages.Add();
HtmlFragment htmlFragment = new HtmlFragment(ssHtmlString);
page.Paragraphs.Add(htmlFragment);
doc.Save(stream);

I am also attaching my html string in a docxHTML.docx (173.5 KB)
file. Thanks.

@shubhammawar

Can you please also share the sample PDF document that you have obtained in your environment with above shared code snippet?

PFA the pdf MyPDF (10).pdf (825.5 KB)

@asad.ali PFA the PDF
MyPDF (10).pdf (825.5 KB)

@shubhammawar

Please check the attached sample code and generated PDF document by it. We used this code in our environment to test the scenario and output PDF looks better:

Document document = new Aspose.Pdf.Document
{
 PageInfo = new PageInfo { Margin = new MarginInfo(28, 28, 28, 18) }
};

var pdfPage = document.Pages.Add();
StringBuilder sb = new StringBuilder();
sb.Append(File.ReadAllText(dataDir + "htmlsample.txt"));
HtmlFragment bodyInfo = new HtmlFragment(sb.ToString());
bodyInfo.HtmlLoadOptions = new HtmlLoadOptions()
{
 IsRenderToSinglePage = true,
 PageLayoutOption = HtmlPageLayoutOption.FitToWidestContentWidth
};
pdfPage.Paragraphs.Add(bodyInfo);

document.Save($"{dataDir}outputfromhtmlstring.pdf");

outputfromhtmlstring.pdf (862.6 KB)

Please feel free to let us know in case you still see any issues in the attached PDF.