技術記事

HotPDF Component: Delphi での report output with fonts and images

HotPDF は Delphi/C++Builder アプリケーション向けのネイティブ VCL PDF ライブラリです。外部 PDF ランタイムを配置せずに、PDF 作成、編集、フォーム、注釈、暗号化、デジタル署名、Unicode フォント、標準対応出力、プリフライトレポートを扱えます。

この記事は developers generating invoices, statements, labels, and regulatory report packages from Delphi 向けです。report output with fonts and images を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。

実務上のリスクは reports often fail after deployment because fonts, image compression, DPI, pagination, and locale formatting differ from the developer machine です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。

アーキテクチャ上の判断

Make report assets part of the build contract. approved fonts, embedding mode, fallback policy, and license constraints / image scaling, compression, color profile, transparency, and DPI rules

  • approved fonts, embedding mode, fallback policy, and license constraints
  • image scaling, compression, color profile, transparency, and DPI rules
  • page size, margins, headers, footers, widow control, and overflow policy
  • locale-sensitive formatting for dates, numbers, currency, and addresses

実装フロー

Measure text and images with production resources. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. load template assets from a versioned location and validate availability first
  2. measure text with the same fonts that will be embedded in the final PDF
  3. normalize images before placing them so compression and DPI are predictable
  4. paginate with production margins and record overflow decisions
  5. compare representative output against approved reference PDFs

検証エビデンス

Report diagnostics that reduce layout disputes. Keep these fields with the output or support record.

  • template version, font list, embedded font status, image count, and compression mode
  • page count, overflow warnings, clipped object warnings, and fallback font usage
  • locale profile, currency format, and address layout used for the run
  • visual comparison result for high-value report templates

Template design and PDF generation must share assumptions

A reliable report pipeline owns its fonts, image processing, page boxes, number formats, and pagination rules. Treating those assets as external decoration makes the output unpredictable in service and customer environments.

サポートパッケージの設計

HotPDF Component を展開した後に最も役立つサポートパッケージは、入力、プロファイル、出力、そして失敗した正確な段階を説明するものです

  • template version, font list, embedded font status, image count, and compression mode
  • page count, overflow warnings, clipped object warnings, and fallback font usage
  • locale profile, currency format, and address layout used for the run
  • visual comparison result for high-value report templates
  • terminology snapshot: font embedding, image compression, DPI, pagination

report output with fonts and images に関する技術レビューの注意点

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

  • 判断: approved fonts, embedding mode, fallback policy, and license constraints. 実装上の焦点: measure text with the same fonts that will be embedded in the final PDF. 受け入れ証拠: locale profile, currency format, and address layout used for the run. 回帰の引き金: printer margins are not a reliable substitute for PDF page-box rules
  • 判断: image scaling, compression, color profile, transparency, and DPI rules. 実装上の焦点: normalize images before placing them so compression and DPI are predictable. 受け入れ証拠: visual comparison result for high-value report templates. 回帰の引き金: service accounts may not have the same fonts installed as developer desktops
  • 判断: page size, margins, headers, footers, widow control, and overflow policy. 実装上の焦点: paginate with production margins and record overflow decisions. 受け入れ証拠: template version, font list, embedded font status, image count, and compression mode. 回帰の引き金: transparent PNG assets can change file size or rendering across viewers
  • 判断: locale-sensitive formatting for dates, numbers, currency, and addresses. 実装上の焦点: compare representative output against approved reference PDFs. 受け入れ証拠: page count, overflow warnings, clipped object warnings, and fallback font usage. 回帰の引き金: long customer names and multilingual addresses expose measurement shortcuts

境界ケース

  • service accounts may not have the same fonts installed as developer desktops
  • transparent PNG assets can change file size or rendering across viewers
  • long customer names and multilingual addresses expose measurement shortcuts
  • printer margins are not a reliable substitute for PDF page-box rules

Delphi / C++Builder の補足

HotPDF Component should sit behind a small service boundary that receives files, streams, profiles, and credentials, then returns output paths, warnings, metrics, and validation status. 重要な用語には font embedding, image compression, DPI, pagination, page box, report template.

Delphi コード例

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

procedure RenderInvoicePdf(const OutputFile: string; const Invoice: TInvoice);
var
  Pdf: THotPDF;
begin
  Pdf := THotPDF.Create(nil);
  try
    Pdf.FileName := OutputFile;
    Pdf.FontEmbedding := True;
    Pdf.BeginDoc;
    DrawInvoiceHeader(Pdf, Invoice);
    DrawLineItems(Pdf, Invoice.Items);
    DrawImageAssets(Pdf, Invoice.BrandAssets);
    Pdf.EndDoc;
  finally
    Pdf.Free;
  end;
end;

本番チェックリスト

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

製品ドキュメント

HotPDF Component

追加のコード例

Pdf.RegisterUnicodeTTF('C:\ProgramData\MyApp\Fonts\NotoSans.ttf');
Pdf.CurrentPage.SetFont('NotoSans', [], 12);
Pdf.CurrentPage.TextOut(50, 700, 0, WideString('Łódź — Ünïcode test ✓'));
var
  Png: TPngImage;
  Logo: TBitmap;
  LogoIdx: Integer;
begin
  Png := TPngImage.Create;
  Logo := TBitmap.Create;
  try
    Png.LoadFromFile('brand-logo.png');
    Logo.Assign(Png);                       // decode PNG to a bitmap
    LogoIdx := Pdf.AddImage(Logo, icFlate); // lossless for flat-color art
  finally
    Logo.Free;
    Png.Free;
  end;
  // (Index, X, Y, Width, Height, Angle) — not (X1, Y1, X2, Y2)
  Pdf.CurrentPage.ShowImage(LogoIdx, 50, 700, 120, 40, 0);
end;
// Horizontal rule under the table header
Pdf.CurrentPage.SetLineWidth(0.75);
Pdf.CurrentPage.MoveTo(50, 660);
Pdf.CurrentPage.LineTo(545, 660);
Pdf.CurrentPage.Stroke;

// Shaded totals box: X, Y, width, height
Pdf.CurrentPage.SetRGBFillColor(RGB(235, 235, 235));
Pdf.CurrentPage.Rectangle(395, 120, 150, 40);
Pdf.CurrentPage.Fill;