Teknik Makale

PDFium Component: accessible PDF reader design in Delphi

Delphi ve C++Builder uygulamalarına PDFium Component iş akışlarını, Lazarus/FPC projelerine PDFium LCL Component iş akışlarını; görüntüleme, render, formlar, yazdırma, preflight raporları ve standart odaklı doğrulama için kaynak kodlu bileşenlerle ekleyin

Bu yazı Delphi teams building PDF viewers for public-sector, education, healthcare, or internal operations users için hazırlanmıştır. accessible PDF reader design konusunu tek bir bileşen çağrısı olarak değil, üretim düzeyinde belge mühendisliği olarak ele alır

Pratik risk şudur: accessibility cannot be added by a toolbar at the end if focus order, text extraction, color modes, keyboard navigation, and document diagnostics are not part of the viewer architecture. Bu nedenle akışın yazılı sözleşmeye, gözlemlenebilir tanılara ve gerçekçi regresyon dosyalarına ihtiyacı vardır

Mimari kararlar

Design the reader around user tasks, not only pages. keyboard model for page navigation, search, selection, panels, and annotations / focus order between the document viewport, thumbnails, form fields, and side panels

  • keyboard model for page navigation, search, selection, panels, and annotations
  • focus order between the document viewport, thumbnails, form fields, and side panels
  • fallback behavior when a document lacks tags, text, or usable reading order
  • color, zoom, contrast, and speech-assistance modes that do not alter the source file

Uygulama akışı

Combine rendering with semantic inspection. Aşağıdaki sıra, iş akışını Delphi ve C++Builder ekipleri için incelenebilir tutar

  1. define reader tasks and keyboard shortcuts before wiring viewer controls
  2. extract text and document structure where available and expose diagnostics
  3. connect focus updates to page, selection, form field, and annotation events
  4. test zoom, contrast, search, and speech cues on tagged and untagged files
  5. record unsupported document conditions as user-facing warnings

Doğrulama kanıtı

Accessibility evidence to keep with releases. Bu alanları çıktı veya destek kaydıyla birlikte saklayın

  • keyboard path coverage, focus transitions, text extraction status, and search behavior
  • PDF/UA or structure diagnostics when available
  • screen-reader notes for supported controls and viewer panels
  • low-vision mode settings used during verification

Accessible viewing starts with predictable navigation

An accessible PDF reader has to expose document state, keyboard paths, focus changes, text selection, search results, zoom behavior, and low-vision display choices consistently. Rendering accuracy is necessary but not sufficient

Profile ownership and versioning

A named, versioned profile is easier to review than options scattered across forms, scripts, and batch parameters. It also makes support reports readable when customers use older templates or policies

  • keyboard model for page navigation, search, selection, panels, and annotations
  • focus order between the document viewport, thumbnails, form fields, and side panels
  • fallback behavior when a document lacks tags, text, or usable reading order
  • color, zoom, contrast, and speech-assistance modes that do not alter the source file
  • keyboard path coverage, focus transitions, text extraction status, and search behavior
  • PDF/UA or structure diagnostics when available

Mühendislik inceleme notları: accessible PDF reader design

Özelliğin bir demoyu aşıp sürüm, destek ve müşteri eskalasyonu sırasında savunulabilir olduğunu doğrulamak için bu inceleme notlarını kullanın

  • Karar: keyboard model for page navigation, search, selection, panels, and annotations. Uygulama baskı noktası: extract text and document structure where available and expose diagnostics. Kabul kanıtı: screen-reader notes for supported controls and viewer panels. Regresyon tetikleyicisi: contrast filters should be reversible and should not modify the PDF itself
  • Karar: focus order between the document viewport, thumbnails, form fields, and side panels. Uygulama baskı noktası: connect focus updates to page, selection, form field, and annotation events. Kabul kanıtı: low-vision mode settings used during verification. Regresyon tetikleyicisi: image-only PDFs need OCR or a clear warning rather than silent empty text
  • Karar: fallback behavior when a document lacks tags, text, or usable reading order. Uygulama baskı noktası: test zoom, contrast, search, and speech cues on tagged and untagged files. Kabul kanıtı: keyboard path coverage, focus transitions, text extraction status, and search behavior. Regresyon tetikleyicisi: rotated pages and mixed page sizes can break hit-testing and focus cues
  • Karar: color, zoom, contrast, and speech-assistance modes that do not alter the source file. Uygulama baskı noktası: record unsupported document conditions as user-facing warnings. Kabul kanıtı: PDF/UA or structure diagnostics when available. Regresyon tetikleyicisi: thumbnail panes should not trap keyboard users away from the document
  • Karar: keyboard model for page navigation, search, selection, panels, and annotations. Uygulama baskı noktası: define reader tasks and keyboard shortcuts before wiring viewer controls. Kabul kanıtı: screen-reader notes for supported controls and viewer panels. Regresyon tetikleyicisi: contrast filters should be reversible and should not modify the PDF itself
  • Karar: focus order between the document viewport, thumbnails, form fields, and side panels. Uygulama baskı noktası: extract text and document structure where available and expose diagnostics. Kabul kanıtı: low-vision mode settings used during verification. Regresyon tetikleyicisi: image-only PDFs need OCR or a clear warning rather than silent empty text

Sınır durumları

  • image-only PDFs need OCR or a clear warning rather than silent empty text
  • rotated pages and mixed page sizes can break hit-testing and focus cues
  • thumbnail panes should not trap keyboard users away from the document
  • contrast filters should be reversible and should not modify the PDF itself

Delphi / C++Builder notes

PDFium Component should sit behind a small service boundary that receives files, streams, profiles, and credentials, then returns output paths, warnings, metrics, and validation status. Important terms include TPdfView, keyboard navigation, PDF/UA, reading order, focus, low-vision mode

Delphi kod örneği

Aşağıdaki Delphi taslağı bu konu için pratik bir servis sınırını gösterir. Politika kontrollerini, günlüklemeyi ve doğrulamayı dar ürün çağrısı bölümünün dışında tutarak akışı test edilebilir bırakın

procedure TReaderForm.LoadReadingStream(const FileName: string; PageNo: Integer);
begin
  PdfView.LoadFromFile(FileName);
  if (PageNo < 1) or (PageNo > PdfView.PageCount) then
    raise ERangeError.Create('Page number is outside the document');
  FReadingUnits := ExtractTaggedReadingOrder(PdfView, PageNo);
  QueueSpeech(FReadingUnits);
  RenderPagePreview(PageNo);
end;

Üretim kontrol listesi

  • İş akışını boş bir dosyada, normal bir müşteri dosyasında ve en kötü durum dosyasında çalıştırın
  • Oluşturulan PDF'yi hedef görüntüleyici, doğrulayıcı, yazıcı veya aşağı akış uygulamasıyla açın
  • Ürün sürümünü, profil sürümünü, giriş karmasını, çıktı yolunu, geçen süreyi ve uyarı sayısını kaydedin
  • Parolaları, sertifikaları, geçici dosyaları ve müşteri verilerini açık saklama kuralları altında tutun
  • Bir müşteri dosyası yeni bir uç durum ortaya çıkardığında regresyon belgeleri ekleyin

Ürün belgeleri

PDFium Component

Ek kod örnekleri

procedure TReaderForm.PrepareKaraoke(PageNumber: Integer);
begin
  // The view's word boxes come from the page the view displays —
  // setting Pdf.PageNumber alone would not move the view
  PdfView.PageNumber := PageNumber;
  FWordBoxes := PdfView.PageWordBoxes;
end;

procedure TReaderForm.OnTtsWordBoundary(Sender: TObject; CharIndex: Integer);
var
  WordIdx: Integer;
begin
  // TrackReadingWordAt maps the offset AND paints the word cursor
  WordIdx := PdfView.TrackReadingWordAt(FCurrentPage, CharIndex);
  if WordIdx < 0 then
    PdfView.ClearReadingWord;  // boundary ran past the page text
end;