Hi,
I’m trying to extract text from pdf file with specific color.
Pdf file is prepared with Aspose.Words. Text color is set to RGB (0,0,254). When I’m reading it in Acrobat Professional, text blue part is still 254. But when I’m trying to check it with Aspose.Pdf I’m getting 253. But if I use RGB (0,0,255) on word doc in Aspose.Pdf everything looks Ok.
Tested with Aspose.Pdf 7.1 and 7.4.
[Test]
public void Correct_Text_Color()
{
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);
docBuilder.ParagraphFormat.Style.Font.Color = System.Drawing.Color.FromArgb(0, 0, 254);
docBuilder.Write(“Text”);
doc.Save(“Bluetext.pdf”, SaveFormat.Pdf);
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(“Bluetext.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
pdfDoc.Pages[1].Accept(textFragmentAbsorber);
foreach (TextFragment textFragment in textFragmentAbsorber.TextFragments)
{
Assert.AreEqual(254, textFragment.TextState.ForegroundColor.B, “Incorrect foreground color!”);
[//Assert.AreEqual](https://assert.areequal/)(“ff0000fe”, textFragment.TextState.ForegroundColor.Name, “Incorrect foreground color!”);
}
}
Regards
Jacek Bator