Create Custom Predefined CMaps Provider
Product Version | Product | Author |
---|---|---|
2021.1.118 | RadPdfProcessing | Martin Velikov |
Description
How to create a custom implementation of the PredefinedCMapsProviderBase in order to use a custom CMAP table.
Solution
This functionality could be achieved by creating a custom class inheriting the PredefinedCMapsProviderBase and passing it to PredefinedCMapsProvider property of the FixedExtensibilityManager class.
Creating a custom class inheriting PredefinedCMapsProviderBase
internal class CustomPredefinedCMapsProvider : PredefinedCMapsProviderBase
{
private readonly PredefinedCMapsProviderBase predefinedCMapsProvider;
public CustomPredefinedCMapsProvider(PredefinedCMapsProviderBase predefinedCMapsProvider)
{
this.predefinedCMapsProvider = predefinedCMapsProvider;
}
public override byte[] GetCidCMapData(string name)
{
if (name == "90ms-RKSJ-V")
{
return File.ReadAllBytes("90ms-RKSJ-V");
}
return this.predefinedCMapsProvider.GetCidCMapData(name);
}
public override byte[] GetUnicodeCMapData(string name)
{
return this.predefinedCMapsProvider.GetUnicodeCMapData(name);
}
}
Set the custom PredefinedCMapsProvider the FixedExtensibilityManager.PredefinedCMapsProvider
FixedExtensibilityManager.PredefinedCMapsProvider = new CustomPredefinedCMapsProvider(new PredefinedCMapsProvider());