技術記事

PDFlibPas: Delphi での tagged PDF accessibility structure

losLab PDF Library は、Delphi/C++Builder チーム向けにソース提供の PDF エンジンを提供します。デスクトップ、サーバー、DLL、ActiveX、Dylib ワークフローで使え、PDF/A・PDF/UA チェック、PAdES 署名、複数レンダラーを外部 PDF サービスなしで利用できます。

この記事は developers generating accessible reports, statements, manuals, or public documents from Delphi 向けです。tagged PDF accessibility structure を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。

実務上のリスクは a PDF can contain text and still be inaccessible if headings, tables, artifacts, alternate text, and reading order are missing or wrong です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。

アーキテクチャ上の判断

Design semantic structure while generating content. heading levels, paragraphs, lists, tables, figures, artifacts, and role mapping / alternate text ownership for charts, logos, signatures, and decorative images

  • heading levels, paragraphs, lists, tables, figures, artifacts, and role mapping
  • alternate text ownership for charts, logos, signatures, and decorative images
  • reading order for multi-column, repeated-header, and mixed-language content
  • validation profile and manual review process for generated samples

実装フロー

Treat tags as document data, not decoration. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. build a semantic outline in parallel with visual layout
  2. tag content as it is emitted so page geometry and structure stay aligned
  3. mark decorative elements as artifacts and supply alternate text for meaningful images
  4. validate PDF/UA-related diagnostics and inspect reading order manually
  5. keep accessible reference samples for every report template family

検証エビデンス

Accessibility evidence for generated PDFs. Keep these fields with the output or support record.

  • structure tree summary, role map, heading order, table structure, and artifact count
  • alternate text coverage for figures and chart-like content
  • reading-order review notes for representative pages
  • PDF/UA diagnostic report and remediation decisions

Reading order is an authoring responsibility

Tagged PDF output requires a structure tree, role mapping, alternate text, table relationships, artifacts, and reading order that match the visual document. Retrofitting those semantics after layout is far harder.

Decision table for tagged PDF accessibility structure

A decision table keeps product ownership visible when the same workflow is reused by a desktop tool, service job, and support utility.

DecisionEngineering reasonEvidence
heading levels, paragraphs, lists, tables, figures, artifacts, and role mappingbuild a semantic outline in parallel with visual layoutstructure tree summary, role map, heading order, table structure, and artifact count
alternate text ownership for charts, logos, signatures, and decorative imagestag content as it is emitted so page geometry and structure stay alignedalternate text coverage for figures and chart-like content
reading order for multi-column, repeated-header, and mixed-language contentmark decorative elements as artifacts and supply alternate text for meaningful imagesreading-order review notes for representative pages

tagged PDF accessibility structure に関する技術レビューの注意点

これらのレビュー項目を使って、機能がデモ段階を超え、リリース、サポート、顧客エスカレーションの場で説明できることを確認します

  • 判断: heading levels, paragraphs, lists, tables, figures, artifacts, and role mapping. 実装上の焦点: tag content as it is emitted so page geometry and structure stay aligned. 受け入れ証拠: reading-order review notes for representative pages. 回帰の引き金: images with text may need both alternate text and source-data access
  • 判断: alternate text ownership for charts, logos, signatures, and decorative images. 実装上の焦点: mark decorative elements as artifacts and supply alternate text for meaningful images. 受け入れ証拠: PDF/UA diagnostic report and remediation decisions. 回帰の引き金: visual headers repeated on every page should often be artifacts
  • 判断: reading order for multi-column, repeated-header, and mixed-language content. 実装上の焦点: validate PDF/UA-related diagnostics and inspect reading order manually. 受け入れ証拠: structure tree summary, role map, heading order, table structure, and artifact count. 回帰の引き金: tables need header relationships, not only drawn grid lines
  • 判断: validation profile and manual review process for generated samples. 実装上の焦点: keep accessible reference samples for every report template family. 受け入れ証拠: alternate text coverage for figures and chart-like content. 回帰の引き金: multi-column pages can read incorrectly if tags follow drawing order
  • 判断: heading levels, paragraphs, lists, tables, figures, artifacts, and role mapping. 実装上の焦点: build a semantic outline in parallel with visual layout. 受け入れ証拠: reading-order review notes for representative pages. 回帰の引き金: images with text may need both alternate text and source-data access
  • 判断: alternate text ownership for charts, logos, signatures, and decorative images. 実装上の焦点: tag content as it is emitted so page geometry and structure stay aligned. 受け入れ証拠: PDF/UA diagnostic report and remediation decisions. 回帰の引き金: visual headers repeated on every page should often be artifacts

境界ケース

  • visual headers repeated on every page should often be artifacts
  • tables need header relationships, not only drawn grid lines
  • multi-column pages can read incorrectly if tags follow drawing order
  • images with text may need both alternate text and source-data access

Delphi / C++Builder の補足

PDFlibPas should sit behind a small service boundary that receives files, streams, profiles, and credentials, then returns output paths, warnings, metrics, and validation status. 重要な用語には tagged PDF, structure tree, role map, alternate text, artifact, reading order.

Delphi コード例

次の Delphi スケッチは、このテーマに対する実用的なサービス境界を示します。ポリシー確認、ログ記録、検証を製品呼び出しの狭い部分の外側に置くと、ワークフローをテストしやすくなります。

procedure InspectTaggedStructure(const FileName: string);
var
  Pdf: TPDFlib;
begin
  Pdf := TPDFlib.Create;
  try
    Pdf.LoadFromFile(FileName, '');
    FTagReport := BuildStructureTreeReport(Pdf);
    RequireAltTextForFigures(FTagReport);
    RequireLogicalReadingOrder(FTagReport);
  finally
    Pdf.Free;
  end;
end;

本番チェックリスト

  • ワークフローは、空のファイル、通常の顧客ファイル、最悪ケースのファイルで実行します
  • 生成された PDF は、対象のビューアー、検証ツール、プリンター、または downstream アプリケーションで開きます
  • 製品バージョン、プロファイルバージョン、入力ハッシュ、出力パス、経過時間、警告数を記録します
  • パスワード、証明書、一時ファイル、顧客データは明確な保持ルールの下で管理します
  • 顧客ファイルが新しい境界ケースを示したら、回帰用ドキュメントを追加します

製品ドキュメント

PDFlibPas

追加のコード例

Lib.BeginTag('Table', '', '');
Lib.BeginTag('TR', '', '');
Lib.BeginTagEx2('TH', '', '', '', '', 'col-part', '');
Lib.SetStructElemScope('Column');          // valid only while this TH is open
Lib.DrawText(72, 120, 'Part');
Lib.EndTag;
Lib.BeginTagEx2('TH', '', '', '', '', 'col-torque', '');
Lib.SetStructElemScope('Column');
Lib.SetStructElemColSpan(2);               // header spans the value and unit columns
Lib.DrawText(200, 120, 'Tightening torque');
Lib.EndTag;
Lib.EndTag;
Lib.BeginTag('TR', '', '');
Lib.BeginTag('TD', '', '');
Lib.SetStructElemHeaders('col-part');      // explicit binding for irregular tables
Lib.DrawText(72, 140, 'M8 flange bolt');
Lib.EndTag;
Lib.EndTag;
Lib.EndTag; // Table