losLab PDF Library は、Delphi/C++Builder チーム向けにソース提供の PDF エンジンを提供します。デスクトップ、サーバー、DLL、ActiveX、Dylib ワークフローで使え、PDF/A・PDF/UA チェック、PAdES 署名、複数レンダラーを外部 PDF サービスなしで利用できます。
この記事は teams building PDF analysis, migration, search, evidence capture, or support-inspection tools 向けです。テキスト、画像、フォントの抽出 を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。
実務上のリスクは extraction output is easy to over-trust even though PDF content order, font encoding, image color spaces, and page resources rarely match user-visible reading order exactly です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。
アーキテクチャ上の判断
Separate extraction facts from interpretation. whether output needs visual order, content-stream order, or search-oriented order / image extraction format, color conversion, compression retention, and naming
- whether output needs visual order, content-stream order, or search-oriented order
- image extraction format, color conversion, compression retention, and naming
- font subset naming, encoding diagnostics, and missing ToUnicode handling
- confidence flags for OCR layers, hidden text, clipped content, and rotated pages
実装フロー
Preserve page and resource context. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- scan page resources and content streams while preserving object references
- extract text runs with coordinates, font identity, Unicode mapping, and style signals
- extract images with page location, dimensions, color space, and original object data when needed
- classify fonts by subset, embedded status, and encoding behavior
- produce an analysis report that distinguishes facts from inferred reading order
検証エビデンス
Extraction evidence that remains explainable. Keep these fields with the output or support record.
- page number, object reference, coordinates, decoded text, font, and confidence
- image size, color space, compression, mask, and export filename
- font subset name, embedded state, encoding map, and ToUnicode status
- warnings for hidden, clipped, rotated, or overlapping content
Extracted text is not always authored text
A professional extraction workflow should record where each text run, image, and font resource came from, how it was decoded, and which assumptions were used to group it into searchable or reviewable content.
サポートパッケージの設計
PDFlibPas を展開した後に最も役立つサポートパッケージは、入力、プロファイル、出力、そして失敗した正確な段階を説明するものです
- page number, object reference, coordinates, decoded text, font, and confidence
- image size, color space, compression, mask, and export filename
- font subset name, embedded state, encoding map, and ToUnicode status
- warnings for hidden, clipped, rotated, or overlapping content
- terminology snapshot: text extraction, image extraction, font resource, ToUnicode
テキスト、画像、フォントの抽出 に関する技術レビューの注意点
これらのレビュー項目を使って、機能がデモ段階を超え、リリース、サポート、顧客エスカレーションの場で説明できることを確認します
- 判断: whether output needs visual order, content-stream order, or search-oriented order. 実装上の焦点: extract text runs with coordinates, font identity, Unicode mapping, and style signals. 受け入れ証拠: font subset name, embedded state, encoding map, and ToUnicode status. 回帰の引き金: OCR layers can contain stale or misaligned text over scanned pages
- 判断: image extraction format, color conversion, compression retention, and naming. 実装上の焦点: extract images with page location, dimensions, color space, and original object data when needed. 受け入れ証拠: warnings for hidden, clipped, rotated, or overlapping content. 回帰の引き金: PDF drawing order may not equal human reading order
- 判断: font subset naming, encoding diagnostics, and missing ToUnicode handling. 実装上の焦点: classify fonts by subset, embedded status, and encoding behavior. 受け入れ証拠: page number, object reference, coordinates, decoded text, font, and confidence. 回帰の引き金: ligatures and custom encodings can make copied text differ from visible text
- 判断: confidence flags for OCR layers, hidden text, clipped content, and rotated pages. 実装上の焦点: produce an analysis report that distinguishes facts from inferred reading order. 受け入れ証拠: image size, color space, compression, mask, and export filename. 回帰の引き金: images may be masks, soft masks, or repeated resources rather than standalone pictures
- 判断: whether output needs visual order, content-stream order, or search-oriented order. 実装上の焦点: scan page resources and content streams while preserving object references. 受け入れ証拠: font subset name, embedded state, encoding map, and ToUnicode status. 回帰の引き金: OCR layers can contain stale or misaligned text over scanned pages
- 判断: image extraction format, color conversion, compression retention, and naming. 実装上の焦点: extract text runs with coordinates, font identity, Unicode mapping, and style signals. 受け入れ証拠: warnings for hidden, clipped, rotated, or overlapping content. 回帰の引き金: PDF drawing order may not equal human reading order
- 判断: font subset naming, encoding diagnostics, and missing ToUnicode handling. 実装上の焦点: extract images with page location, dimensions, color space, and original object data when needed. 受け入れ証拠: page number, object reference, coordinates, decoded text, font, and confidence. 回帰の引き金: ligatures and custom encodings can make copied text differ from visible text
境界ケース
- PDF drawing order may not equal human reading order
- ligatures and custom encodings can make copied text differ from visible text
- images may be masks, soft masks, or repeated resources rather than standalone pictures
- OCR layers can contain stale or misaligned text over scanned pages
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. 重要な用語には text extraction, image extraction, font resource, ToUnicode, content stream, coordinates.
Delphi コード例
次の Delphi スケッチは、このテーマに対する実用的なサービス境界を示します。ポリシー確認、ログ記録、検証を製品呼び出しの狭い部分の外側に置くと、ワークフローをテストしやすくなります。
procedure ExtractForIndexing(const FileName, OutputDir: string);
var
Pdf: TPDFlib;
begin
Pdf := TPDFlib.Create;
try
Pdf.LoadFromFile(FileName, '');
SaveExtractedText(OutputDir, ExtractDocumentText(Pdf));
SaveEmbeddedImages(OutputDir, ExtractDocumentImages(Pdf));
SaveFontInventory(OutputDir, BuildFontInventory(Pdf));
finally
Pdf.Free;
end;
end;
本番チェックリスト
- ワークフローは、空のファイル、通常の顧客ファイル、最悪ケースのファイルで実行します
- 生成された PDF は、対象のビューアー、検証ツール、プリンター、または downstream アプリケーションで開きます
- 製品バージョン、プロファイルバージョン、入力ハッシュ、出力パス、経過時間、警告数を記録します
- パスワード、証明書、一時ファイル、顧客データは明確な保持ルールの下で管理します
- 顧客ファイルが新しい境界ケースを示したら、回帰用ドキュメントを追加します
製品ドキュメント
追加のコード例
var
ImgList, I: Integer;
begin
Pdf.SelectPage(1);
ImgList := Pdf.GetPageImageList(0);
for I := 0 to Pdf.GetImageListCount(ImgList) - 1 do
begin
Writeln(Pdf.GetImageListItemFormatDesc(ImgList, I, 0));
Pdf.SaveImageListItemDataToFile(ImgList, I, 0,
Format('page1-img%.2d.bin', [I]));
end;
Pdf.ReleaseImageList(ImgList);
end;var
I: Integer;
begin
Pdf.FindFonts;
for I := 1 to Pdf.FontCount do // font indexes start at 1, not 0
if Pdf.SelectFont(Pdf.GetFontID(I)) = 1 then
Writeln(Format('%s type=%d embedded=%d subset=%d',
[Pdf.FontName, Pdf.FontType,
Pdf.GetFontIsEmbedded, Pdf.GetFontIsSubsetted]));
end;