PDF 문서에 사용된 글꼴을 이해하는 것은 품질 관리, 접근성 준수 및 문서 분석에 필수적입니다. 글꼴 속성 데모는 PDFium VCL을 사용하여 PDF의 문자 글꼴에 대한 자세한 정보를 얻는 방법을 보여줍니다.
개요
이 데모를 사용하면 PDF의 모든 문자를 클릭하고 글꼴 패밀리 이름, 두께, 스타일, 크기 및 글꼴이 포함되어 있는지 여부와 같은 글꼴 속성을 확인할 수 있습니다. PDF 분석 및 문제 해결에 매우 유용합니다.
주요 기능
- 대화형 선택 – 분석할 문자를 클릭합니다.
- 글꼴 패밀리 이름 – 글꼴 패밀리 (예: "Arial", "Times New Roman")
- 글꼴 기본 이름 – 내부 PDF 글꼴 이름
- 글꼴 두께 – 숫자 두께 값 (400 = 일반, 700 = 굵게)
- 글꼴 크기 – 포인트 단위의 크기
- 이탤릭 각도 – 이탤릭 글꼴의 기울기 각도
- Ascent/Descent – 수직 메트릭
- 임베디드 상태 – 글꼴이 PDF에 포함되어 있는지 여부
- 글꼴 데이터 – 포함된 경우, 원시 글꼴 데이터에 접근
PDFium DLL 요구 사항
PDFium VCL 애플리케이션을 실행하기 전에, PDFium DLL 파일이 설치되어 있는지 확인하십시오.
pdfium32.dll/pdfium64.dll– 표준 버전 (약 5-6 MB)pdfium32v8.dll/pdfium64v8.dll– V8 JavaScript 엔진 포함 (약 23-27 MB)
설치: 실행 PDFiumVCL\DLLs\CopyDlls.bat 관리자 권한으로 실행하여 DLL 파일을 Windows 시스템 디렉터리에 자동으로 복사합니다.
글꼴 속성 접근
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
procedure TfrmMain.UpdateFontInfo; var FontInfo: TStringList; begin FontInfo := TStringList.Create; try FontInfo.Add('=== Font Properties for Character Index: ' + IntToStr(PdfView.CurrentCharIndex) + ' ==='); FontInfo.Add(''); // Font family name try FontInfo.Add('Font Family Name: ' + PdfView.FontFamilyName); except FontInfo.Add('Font Family Name: \u003cError retrieving\u003e'); end; // Font base name (internal PDF name) try FontInfo.Add('Font Base Name: ' + PdfView.FontBaseName); except FontInfo.Add('Font Base Name: \u003cError retrieving\u003e'); end; // Font size for this character try FontInfo.Add('Font Size: ' + FloatToStr(PdfView.FontSize[PdfView.CurrentCharIndex])); except FontInfo.Add('Font Size: \u003cError retrieving\u003e'); end; // Font weight (400=normal, 700=bold) try FontInfo.Add('Font Weight: ' + IntToStr(PdfView.FontWeight)); except FontInfo.Add('Font Weight: \u003cError retrieving\u003e'); end; // Italic angle (0 for upright, negative for italic) try FontInfo.Add('Font Italic Angle: ' + IntToStr(PdfView.FontItalicAngle)); except FontInfo.Add('Font Italic Angle: \u003cError retrieving\u003e'); end; // Vertical metrics try FontInfo.Add('Font Ascent: ' + FloatToStr(PdfView.FontAscent)); except FontInfo.Add('Font Ascent: \u003cError retrieving\u003e'); end; try FontInfo.Add('Font Descent: ' + FloatToStr(PdfView.FontDescent)); except FontInfo.Add('Font Descent: \u003cError retrieving\u003e'); end; // Embedded status try FontInfo.Add('Font Is Embedded: ' + BoolToStr(PdfView.FontIsEmbedded, True)); except FontInfo.Add('Font Is Embedded: \u003cError retrieving\u003e'); end; // Font data size (if embedded) try FontInfo.Add('Font Data Size: ' + IntToStr(Length(PdfView.FontData)) + ' bytes'); except FontInfo.Add('Font Data Size: \u003cError retrieving\u003e'); end; FontInfo.Add(''); FontInfo.Add('Character: ' + PdfView.Character[PdfView.CurrentCharIndex]); memoFontInfo.Lines.Assign(FontInfo); finally FontInfo.Free; end; end; |
분석할 문자를 클릭하세요.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
procedure TfrmMain.PdfViewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var CharIndex: Integer; begin if not PdfView.Active then Exit; try // Get character at click position CharIndex := PdfView.CharacterIndexAtPos(X, Y, 10.0, 10.0); if CharIndex >= 0 then begin edtCharIndex.Text := IntToStr(CharIndex); PdfView.CurrentCharIndex := CharIndex; UpdateFontInfo; end; except on E: Exception do begin memoFontInfo.Lines.Clear; memoFontInfo.Lines.Add('Error getting character: ' + E.Message); end; end; end; |
수동 문자 인덱스 입력
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
procedure TfrmMain.btnGetFontInfoClick(Sender: TObject); var CharIndex: Integer; begin if not PdfView.Active then begin ShowMessage('Please open a PDF file first.'); Exit; end; try CharIndex := StrToInt(edtCharIndex.Text); PdfView.CurrentCharIndex := CharIndex; UpdateFontInfo; except on E: Exception do ShowMessage('Invalid character index: ' + E.Message); end; end; |
사용 가능한 글꼴 속성
PDFium VCL은 다음과 같은 글꼴 관련 속성을 제공합니다.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Font properties accessible via TPdf and TPdfView property FontFamilyName: WString; // e.g., "Arial", "Times New Roman" property FontBaseName: WString; // Internal PDF font name property FontWeight: Integer; // 100-900, 400=normal, 700=bold property FontItalicAngle: Integer; // Degrees, 0=upright, negative=italic property FontAscent: Single; // Height above baseline property FontDescent: Single; // Depth below baseline (negative) property FontIsEmbedded: Boolean; // True if font is embedded property FontData: TBytes; // Raw font data if embedded property FontHandle: FPDF_FONT; // PDFium font handle // Per-character property property FontSize[Index: Integer]: Double; // Font size for character |
분석을 위한 글꼴 속성 사용
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
procedure AnalyzeDocumentFonts(Pdf: TPdf); var FontList: TStringList; I: Integer; FontName: string; LastFontName: string; begin FontList := TStringList.Create; FontList.Sorted := True; FontList.Duplicates := dupIgnore; try Pdf.PageNumber := 1; LastFontName := ''; for I := 0 to Pdf.CharacterCount - 1 do begin // Access font for each character // (In practice, use CurrentCharIndex pattern) // Check FontFamilyName changes // Add unique fonts to list end; ShowMessage('Document uses ' + IntToStr(FontList.Count) + ' fonts'); finally FontList.Free; end; end; |
글꼴 포함 여부 확인
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
procedure CheckFontEmbedding(Pdf: TPdf); var EmbeddedFonts, NonEmbeddedFonts: TStringList; begin EmbeddedFonts := TStringList.Create; NonEmbeddedFonts := TStringList.Create; try EmbeddedFonts.Sorted := True; EmbeddedFonts.Duplicates := dupIgnore; NonEmbeddedFonts.Sorted := True; NonEmbeddedFonts.Duplicates := dupIgnore; // Analyze fonts... if NonEmbeddedFonts.Count > 0 then begin ShowMessage('Warning: ' + IntToStr(NonEmbeddedFonts.Count) + ' fonts are not embedded. Document may not display correctly ' + 'on systems without these fonts installed.'); end else begin ShowMessage('All fonts are embedded. Document will display ' + 'consistently on all systems.'); end; finally EmbeddedFonts.Free; NonEmbeddedFonts.Free; end; end; |
포함된 글꼴 데이터 추출
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
procedure ExtractEmbeddedFont(Pdf: TPdf; const OutputFile: string); var FontData: TBytes; FileStream: TFileStream; begin if Pdf.FontIsEmbedded then begin FontData := Pdf.FontData; if Length(FontData) > 0 then begin FileStream := TFileStream.Create(OutputFile, fmCreate); try FileStream.WriteBuffer(FontData[0], Length(FontData)); ShowMessage('Font extracted: ' + IntToStr(Length(FontData)) + ' bytes'); finally FileStream.Free; end; end; end else ShowMessage('Font is not embedded in the document.'); end; |
글꼴 두께 값 이해
| Weight Value | Common Name |
|---|---|
| 100 | Thin |
| 200 | Extra Light |
| 300 | Light |
| 400 | Normal/Regular |
| 500 | Medium |
| 600 | Semi Bold |
| 700 | Bold |
| 800 | Extra Bold |
| 900 | Black |
사용 사례
- 품질 관리 – 문서에서 올바른 글꼴이 사용되었는지 확인
- 접근성 – 글꼴이 접근성 요구 사항을 충족하는지 확인
- 법의학 분석 – 문서의 출처 및 수정 사항 분석
- 인쇄 사전 검토 – 생산 전에 글꼴 포함 여부 확인
- 글꼴 목록 – 문서 전체에서 사용되는 글꼴 목록 작성
결론
Font Properties 데모는 PDFium VCL이 PDF 문서의 글꼴 정보에 대한 심층적인 접근 방식을 제공하는 방법을 보여줍니다. 인쇄 제작을 위해 글꼴 포함 여부를 확인하거나 문서의 서체 구성을 분석하든, 이러한 API는 필요한 도구를 제공합니다.
모든 문자를 클릭하고 즉시 해당 글꼴 속성을 확인할 수 있는 기능은 PDF 분석을 직관적이고 효율적으로 만듭니다.
PDF 글꼴을 심층적으로 살펴봅니다. PDFium Delphi VCL 컴포넌트..