Unplanned
Last Updated: 10 Nov 2020 15:27 by ADMIN
Mingchang
Created on: 10 Nov 2020 15:22
Category: PDFViewer
Type: Feature Request
1
PdfViewer: Add support for extracting text from composite fonts with no ToUnicode mapping

When extracting text from a composite font the ToUnicode mapping should be used but when this mapping is missing the char codes must be mapped by constructing a secondary map from fonts ordering and registry. 

A possible workaround could be to register a TrueType font using the FontsRepository.RegisterFont() method:

FontsRepository.RegisterFont(new FontFamily(fontName), FontStyles.Normal, FontWeights.Normal, File.ReadAllBytes(pathToFont));
and then to iterate the document content and change the specific font with the registered one:
FontsRepository.TryCreateFont(new FontFamily(fontName), FontStyles.Normal, FontWeights.Normal, out FontBase font);

foreach (RadFixedPage page in document.Pages)
{
	foreach (ContentElementBase contentElement in page.Content)
	{
		if (contentElement is TextFragment textFragment)
		{
			if (textFragment.Font.Name == fontName)
			{
				textFragment.Font = font;
			}
		}
	}
}

0 comments