텍스트를 상태로 바꾸기
Contents
[
Hide
]
텍스트를 사용자 정의 텍스트 상태로 바꾸기
- 소스 PDF를
PdfContentEditor파사드에 바인딩하세요. - 필요한 색상과 글꼴 크기로
TextState를 만들고 구성하세요. - 대체 텍스트 범위를
ReplaceAll으로 설정하세요. - 검색 텍스트, 대체 텍스트 및 구성된
TextState를 사용하여replaceText(...)를 호출하세요. - 업데이트된 PDF 문서를 저장하세요.
public static void replaceTextWithState(Path inputFile, Path outputFile) {
PdfContentEditor editor = new PdfContentEditor();
try {
editor.bindPdf(inputFile.toString());
TextState textState = new TextState();
textState.setForegroundColor(com.aspose.pdf.Color.getBlue());
textState.setFontSize(14);
editor.getReplaceTextStrategy().setReplaceScope(ReplaceTextStrategy.Scope.ReplaceAll);
editor.replaceText("software", "SOFTWARE", textState);
editor.save(outputFile.toString());
} finally {
editor.close();
}
}