이미지에 속성 설정하기
Contents
[
Hide
]
글꼴 캐시 업데이트
Aspose.PSD를 사용하여 Java 개발자는 글꼴 캐시를 새로 고칠 수 있습니다. 아래는 해당 기능의 코드 시연입니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(ForceFontCache.class) + "DrawingAndFormattingImages/"; | |
try (PsdImage image = (PsdImage) Image.load(dataDir + "sample.psd")) { | |
image.save(dataDir + "NoFont.psd"); | |
} | |
System.out.println("You have 2 minutes to install the font"); | |
Thread.sleep(2 * 60 * 1000); | |
OpenTypeFontsCache.updateCache(); | |
try (PsdImage image1 = (PsdImage) Image.load(dataDir + "sample.psd")) { | |
image1.save(dataDir + "HasFont.psd"); | |
} |
누락된 글꼴에 대한 대체 설정하기
Aspose.PSD를 사용하여 Java 개발자는 누락된 글꼴을 대체할 수 있습니다. 아래 샘플 코드를 사용하면 PSD 문서를 래스터 이미지(포맷: PNG, JPG 및 BMP)로 저장할 때 기본 글꼴 이름을 설정할 수 있습니다. 이 기본 글꼴은 현재 운영 체제에서 찾을 수 없는 글꼴, 즉 누락된 글꼴을 대체로 사용해야 합니다. 아래는 해당 기능의 코드 시연입니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(FontReplacement.class) + "DrawingAndFormattingImages/"; | |
// Load an image in an instance of image and setting default replacement font. | |
PsdLoadOptions psdLoadOptions = new PsdLoadOptions(); | |
psdLoadOptions.setDefaultReplacementFont("Arial"); | |
try (PsdImage psdImage = (PsdImage) Image.load(dataDir + "Cloud_AzPlat_Banner3A_SB_EN_US_160x600_chinese_font.psd", psdLoadOptions)) { | |
PngOptions pngOptions = new PngOptions(); | |
psdImage.save(dataDir + "replaced_font.png", pngOptions); | |
} |