폼 필드의 사용자 정의 폰트
대화형 양식 필드를 스타일링할 때, SetFont() 메서드는 사용자 정의 글꼴을 적용할 수 없습니다. 오류는 없습니다; 폰트 요청이 단순히 무시되어 필드는 기본 모양을 유지합니다.
사용자 정의 글꼴 스타일링은 아직 SetFont()을 통해 지원되지 않습니다. 차기 릴리스에서 지원될 때까지, 글꼴, 크기, 색상을 필드의 DefaultAppearance 속성을 통해 직접 조정할 수 있으며, 이는 원시 PDF 그리기 명령어 문자열을 받습니다.
해결책
1. 외관 문자열을 수동으로 설정하기
문서를 로드하고, 필드를 가져와 글꼴, 크기, 색상을 설명하는 DefaultAppearance 문자열을 할당하십시오:
var pdf = PdfDocument.FromFile("FilledForm.pdf");
TextFormField field = pdf.Form[0] as TextFormField;
// Manually define the appearance string:
// Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg";
field.Value = "This is size 15";
pdf.SaveAs("customformfieldvalue15.pdf");
var pdf = PdfDocument.FromFile("FilledForm.pdf");
TextFormField field = pdf.Form[0] as TextFormField;
// Manually define the appearance string:
// Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg";
field.Value = "This is size 15";
pdf.SaveAs("customformfieldvalue15.pdf");
Imports System
Dim pdf = PdfDocument.FromFile("FilledForm.pdf")
Dim field As TextFormField = TryCast(pdf.Form(0), TextFormField)
' Manually define the appearance string:
' Format: /{FontName}-{Weight} {FontSize} Tf {R} {G} {B} rg
field.DefaultAppearance = "/AdobeThai-Bold 15 Tf 0.898 0.133 0.215 rg"
field.Value = "This is size 15"
pdf.SaveAs("customformfieldvalue15.pdf")
문자열은 PDF 텍스트 연산자로 해석되므로 지정한 폰트는 문서를 렌더링하는 기계에 설치되어 있어야 합니다.
2. 외관 문자열 읽기
문자열의 각 토큰은 필드의 스타일링의 한 부분에 매핑됩니다:
/AdobeThai-Bold: 글꼴 이름과 굵기. 이 폰트는 시스템에 설치되어 있어야 합니다.15 Tf: 글꼴 크기, 여기서는 15 pt.0.898 0.133 0.215 rg: RGB 색상, 이 경우 붉은 색조.
이렇게 하면 나중에 IronPDF의 릴리스에서 SetFont() 지원이 도착할 때까지 양식 필드 텍스트의 글꼴과 색상을 완전히 제어할 수 있습니다.

