Setting Properties on Images
Updating Fonts cache
Using Aspose.PSD for .NET, developers can add possibility to refresh fonts cache. Below is the code demonstration of the said functionality.
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
using (PsdImage image = (PsdImage)Image.Load(dataDir + "sample.psd")) | |
{ | |
image.Save("NoFont.psd"); | |
} | |
Console.WriteLine("You have 2 minutes to install the font"); | |
Thread.Sleep(TimeSpan.FromMinutes(2)); | |
OpenTypeFontsCache.UpdateCache(); | |
using (PsdImage image = (PsdImage)Image.Load(dataDir + @"sample.psd")) | |
{ | |
image.Save(dataDir + "HasFont.psd"); | |
} |
Setting replacement for missing Fonts
Using Aspose.PSD for .NET, developers can replace missing fonts. Using below sample code developers will be able to set default font name when saving PSD documents as raster image (into PNG, JPG and BMP formats). This default font should be used as a replacement for all missing fonts means fonts that are not found in current Operating System. Below is the code demonstration of the said functionality.
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
string sourceFileName = "sample_konstanting.psd"; | |
string[] outputs = new string[] | |
{ | |
"replacedfont0.tiff", | |
"replacedfont1.png", | |
"replacedfont2.jpg" | |
}; | |
using (PsdImage image = (PsdImage)Image.Load(sourceFileName, new PsdLoadOptions())) | |
{ | |
// This way you can use different fonts for different outputs | |
image.Save(outputs[0], new TiffOptions(TiffExpectedFormat.TiffJpegRgb) { DefaultReplacementFont = "Arial" }); | |
image.Save(outputs[1], new PngOptions { DefaultReplacementFont = "Verdana" }); | |
image.Save(outputs[2], new JpegOptions { DefaultReplacementFont = "Times New Roman" }); | |
} |