Teknik makale

HotPDF: report output with fonts and images in Delphi

HotPDF, harici bir PDF runtime kurmadan doğrudan PDF oluşturma ve düzenleme, formlar, notlar, şifreleme, dijital imzalar, Unicode yazı tipleri, standart odaklı çıktı ve preflight raporları gereken Delphi ve C++Builder uygulamaları için yerel bir VCL PDF kütüphanesidir.

Bu yazı developers generating invoices, statements, labels, and regulatory report packages from Delphi için hazırlanmıştır. report output with fonts and images 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: reports often fail after deployment because fonts, image compression, DPI, pagination, and locale formatting differ from the developer machine. 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

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

Uygulama akışı

Measure text and images with production resources. Aşağıdaki sıra, iş akışını Delphi ve C++Builder ekipleri için incelenebilir tutar.

  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

Doğrulama kanıtı

Report diagnostics that reduce layout disputes. Bu alanları çıktı veya destek kaydıyla birlikte saklayın.

  • 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.

Support package design

Once HotPDF Component is deployed, the most valuable support package is the one that explains the input, profile, output, and exact stage that failed.

  • 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

Mühendislik inceleme notları: report output with fonts and images

Ö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: approved fonts, embedding mode, fallback policy, and license constraints. Uygulama baskı noktası: measure text with the same fonts that will be embedded in the final PDF. Kabul kanıtı: locale profile, currency format, and address layout used for the run. Regresyon tetikleyicisi: printer margins are not a reliable substitute for PDF page-box rules
  • Karar: image scaling, compression, color profile, transparency, and DPI rules. Uygulama baskı noktası: normalize images before placing them so compression and DPI are predictable. Kabul kanıtı: visual comparison result for high-value report templates. Regresyon tetikleyicisi: service accounts may not have the same fonts installed as developer desktops
  • Karar: page size, margins, headers, footers, widow control, and overflow policy. Uygulama baskı noktası: paginate with production margins and record overflow decisions. Kabul kanıtı: template version, font list, embedded font status, image count, and compression mode. Regresyon tetikleyicisi: transparent PNG assets can change file size or rendering across viewers
  • Karar: locale-sensitive formatting for dates, numbers, currency, and addresses. Uygulama baskı noktası: compare representative output against approved reference PDFs. Kabul kanıtı: page count, overflow warnings, clipped object warnings, and fallback font usage. Regresyon tetikleyicisi: long customer names and multilingual addresses expose measurement shortcuts

Sınır durumları

  • 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 notes

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. Important terms include font embedding, image compression, DPI, pagination, page box, report template.

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 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;

Ü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

HotPDF Component

Ek kod örnekleri

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;