HTML'si Delphi'de PDFium VCL ile PDF Yazı Tipi Özelliklerini Analiz Etme | losLab Software Development Blog

Teknik makale

Delphi'de PDFium VCL ile PDF Yazı Tipi Özelliklerini Analiz Etme

· PDF Programlama

Bir PDF belgesinde kullanılan yazı tiplerini anlamak, kalite kontrolü, erişilebilirlik uyumluluğu ve belge adli tıp açısından çok önemlidir. Yazı Tipi Özellikleri demosu, PDFium VCL kullanarak bir PDF'deki karakterler için ayrıntılı yazı tipi bilgilerine nasıl erişileceğini gösterir.

Genel Bakış

Bu demo, PDF'deki herhangi bir karaktere tıklamanıza ve aile adı, ağırlık, stil, boyut ve yazı tipinin gömülü olup olmadığı gibi yazı tipi özelliklerini görüntülemenize olanak tanır. PDF analizi ve sorun giderme için çok değerlidir.

Temel Özellikler

  • İnteraktif Seçim – Analiz etmek için herhangi bir karaktere tıklayın
  • Yazı Tipi Ailesi Adı – Yazı tipi ailesi (ör. “Arial”, “Times New Roman”)
  • Yazı Tipi Temel Adı – Dahili PDF yazı tipi adı
  • Yazı Tipi Ağırlığı – Sayısal ağırlık (400 = normal, 700 = kalın)
  • Yazı Tipi Boyutu – Nokta cinsinden boyut
  • İtalik Açı – İtalik yazı tipleri için eğik açı
  • Yükseliş/İniş – Dikey metrikler
  • Katıştırılmış Durum – Yazı tipinin PDF'ye gömülü olup olmadığı
  • Yazı Tipi Verisi – Gömülüyse ham yazı tipi verilerine erişin

PDFium DLL Gereksinimleri

Herhangi bir PDFium VCL uygulamasını çalıştırmadan önce PDFium DLL dosyalarının kurulu olduğundan emin olun:

  • pdfium32.dll / pdfium64.dll – Standart sürümler (~5-6 MB)
  • pdfium32v8.dll / pdfium64v8.dll – V8 JavaScript motoruyla (~23-27 MB)

Kurulum: Çalıştır DLL'leri otomatik olarak Windows sistem dizinlerine kopyalamak için Yönetici olarak PDFiumVCL\DLLs\CopyDlls.bat .

Yazı Tipi Özelliklerine Erişim

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0013 saniye]

Karakteri Analiz Etmek İçin Tıklayın

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0004 saniye]

Manuel Karakter Dizini Girişi

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0004 saniye]

Yazı Tipi Özellikleri Mevcuttur

PDFium VCL, yazı tipiyle ilgili şu özellikleri ortaya çıkarır:

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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
[Format Süresi: 0,0003 saniye]

Analiz için Yazı Tipi Özelliklerini Kullanma

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0003 saniye]

Yazı Tipi Gömme Kontrol Ediliyor

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0003 saniye]

Gömülü Yazı Tipi Verilerini Çıkarma

Urvanov Sözdizimi Vurgulayıcı v2.9.1
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;
[Format Süresi: 0,0003 saniye]

Yazı Tipi Ağırlığı Değerlerini Anlama

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

Kullanım Durumları

  • Kalite Kontrol – Belgelerde doğru yazı tiplerinin kullanıldığını doğrulayın
  • Erişilebilirlik – Yazı tiplerinin erişilebilirlik gereksinimlerini karşıladığını kontrol edin
  • Adli Analiz – Belge kökenlerini ve değişikliklerini analiz edin
  • Baskı Ön Kontrolü – Üretimden önce yazı tipi yerleştirmeyi doğrulayın
  • Yazı Tipi Envanteri – Belgelerde kullanılan katalog yazı tipleri

Sonuç

Yazı Tipi Özellikleri demosu, PDFium VCL'nin PDF belgelerindeki yazı tipi bilgilerine nasıl derin erişim sağladığını gösterir. İster baskı üretimi için yazı tipi yerleştirmeyi kontrol ediyor ister belge tipografisini analiz ediyor olun, bu API'ler size ihtiyacınız olan araçları sağlar.

Herhangi bir karaktere tıklayıp yazı tipi özelliklerini anında görebilme yeteneği, PDF analizini sezgisel ve verimli hale getirir.

PDF yazı tiplerini keşfedin derinlemesine PDFium Delphi VCL Bileşeni.