Hey there.
We noticed a weird behavior when we convert an html string that is using “word-break: break-all” and the span is very large. It breaks line for every word until it can fit the rest of the string in one line, resulting in a very weird output. I’m attaching here 4 files: breakallhtml.html (the html that causes the issue), breakwordhtml.html (this does not cause the issue because I changed the css to use “word-break: break-word”), breakallpdf.pdf and breakwordpdf.pdf which are the resulting files after conversion. You will be able to see clearly what I’m talking about.
The only difference in the HTML is in the css for element .agenda-item-name
I’m using Aspose.PDF version 18.3.0. Here is the code I’m using to do the conversion:
public FileModel convertHTMLToPdf(string htmlString)
{
try
{
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Page page = doc.Pages.Add();
HtmlFragment html = new HtmlFragment(htmlString);
page.Paragraphs.Add(html);
//set margins
var marginInfo = new MarginInfo();
marginInfo.Left = 40;
marginInfo.Right = 40;
marginInfo.Top = 40;
marginInfo.Bottom = 40;
page.PageInfo.Margin = marginInfo;
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, Aspose.Pdf.SaveFormat.Pdf);
var fileModel = new FileModel
{
data = dstStream.ToArray(),
contentType = "application/pdf"
};
return fileModel;
}
catch (Exception e)
{
LogClient.Error("Error converting Html to PDF", e);
return null;
}
}
FilesForAsposeReview.zip (1.2 MB)