Artykuł techniczny

PDFium Component: accessible PDF reader design in Delphi

Integruj workflow PDFium Component w aplikacjach Delphi i C++Builder albo workflow PDFium LCL Component w Lazarus/FPC, z komponentami źródłowymi do podglądu, renderowania, formularzy, drukowania, raportów preflight i walidacji zgodnej ze standardami

Ten artykuł jest przeznaczony dla Delphi teams building PDF viewers for public-sector, education, healthcare, or internal operations users. Traktuje accessible PDF reader design jako produkcyjną inżynierię dokumentów, a nie pojedyncze wywołanie komponentu

Praktyczne ryzyko polega na tym, że 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. Dlatego przepływ wymaga spisanego kontraktu, obserwowalnej diagnostyki i realistycznych plików regresyjnych

Decyzje architektoniczne

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

Przebieg implementacji

Combine rendering with semantic inspection. Poniższa kolejność zachowuje czytelność przepływu pracy dla zespołów Delphi i C++Builder

  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

Dowody walidacji

Accessibility evidence to keep with releases. Zachowaj te pola wraz z wynikiem lub rekordem wsparcia

  • 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

Notatki przeglądu inżynierskiego dla accessible PDF reader design

Użyj tych notatek przeglądu, aby upewnić się, że funkcja wyszła poza demonstrację i da się ją obronić podczas wydania, wsparcia i eskalacji klienta

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

Przypadki brzegowe

  • 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

Przykład kodu Delphi

Poniższy szkic Delphi pokazuje praktyczną granicę usługi dla tego tematu. Kontrole zasad, logowanie i walidację trzymaj poza wąskim blokiem wywołań produktu, aby przepływ pozostał testowalny

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;

Lista produkcyjna

  • Uruchom przepływ pracy na pustym pliku, zwykłym pliku klienta i pliku z najgorszego scenariusza
  • Otwórz wygenerowany plik PDF w docelowej przeglądarce, walidatorze, drukarce lub aplikacji nadrzędnej
  • Zaloguj wersję produktu, wersję profilu, hash wejścia, ścieżkę wyjścia, czas wykonania i liczbę ostrzeżeń
  • Przechowuj hasła, certyfikaty, pliki tymczasowe i dane klienta zgodnie z jednoznacznymi zasadami retencji
  • Dodaj dokument regresyjny, gdy plik klienta ujawni nowy przypadek brzegowy

Dokumentacja produktu

PDFium Component

Dodatkowe przykłady kodu

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;