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

Free Support Forum - aspose.com

Html to PDF : highlighted text is splited

Hello,

I’m working on highlighting text on a PDF, starting with a HTML document.
The HTML document contains elements that are use to highlight text.
After saving the document, we notice that highlighted text containing multiple words are kind of splited into chunks. Please have a look at the screenshot as it might be more explicit.

As you can see, Lead is highlighted, the space between Lead and Developer is highlighted as well, Developer is also highlighted. The problem is that we can see each of them are highlighted separately, because we see thin white line between the words.
Is there a way to fix this behavior?
Kind regards

@mathrb

Can you please share your sample source document and sample code snippet with us as well? We will test the scenario in our environment and address it accordingly.

Hello,
Yes please find below the C# code, and the HTML source file

new Aspose.Words.License().SetLicense("Aspose.Total.lic");
string html = File.ReadAllText("test.html");
Aspose.Words.Document newDoc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(newDoc)
{
    PageSetup =
    {
        Orientation = Aspose.Words.Orientation.Portrait,
        PaperSize = Aspose.Words.PaperSize.A4,
        FooterDistance = 0,
    }
};
builder.InsertHtml(html);
newDoc.Save("test.pdf", Aspose.Words.SaveFormat.Pdf);

And the html

<html>
<meta name="subject" content='{"toto":"88,16,16"}' />
<head>
</head>
<body>
    <p><mark>It seems correctly highlighted (no background-color specified).</mark></p>
    <p><mark style="background-color: yellow;">It seems correctly highlighted (background-color specified yellow).</mark></p>
    <p><mark style="background-color: rgb(50, 255, 1);">Look closely and notice separation between tokens (background-color specified rgb(255, 255, 0)).</mark></p>
    <p><mark style="background-color: rgb(255, 0, 0);">We can easily see the separation between tokens (background-color specified red).</mark></p>
    <p><mark style="background-color: rgb(66, 14, 14);">The darker it is, the easier we see the separation between tokens.</mark></p>
</body>
</html>

@mathrb

The inquiry is related to Aspose.Words and we are moving this topic to respective forum category. You will be assisted there accordingly.

@mathrb I cannot reproduce the problem on my side. Here is PDF document produced on my side: out.pdf (30.0 KB)

Here is the code I used for testing:

Document doc = new Document(@"C:\Temp\in.html");
doc.Save(@"C:\Temp\out.pdf");

I cannot see the mentioned artifacts in the produced PDF document. Could you please attach your output PDF?