Free Support Forum - aspose.com

Weird behavior converting from HTML when using "word-break: break-all"

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)

@fleite

Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-44761 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

1 Like

Any updates on this? Any estimates on when this will be fixed?

Thanks!

@fleite

The issue reported by you has been logged in our issue management system a few weeks ago. Currently, it is pending owing to previously logged tickets and will be investigated on its due turn, that can take several months. We appreciate your patience and comprehension in this regard.

However, we also offer Paid Support, where issues are used to be investigated with higher priority. Our customers, who have paid support subscription, report their issue there which are meant to be investigated urgently. In case your reported issue is a blocker, you may please consider subscribing for Paid Support. For further information, please visit Paid Support FAQs.