기술 문서

PDFium Component: Delphi에서 Lazarus and Free Pascal viewer integration

Delphi와 C++Builder 애플리케이션에는 PDFium VCL Component 워크플로를, Lazarus/FPC에는 PDFium LCL Component 워크플로를 통합하여 보기, 렌더링, 폼, 인쇄, 프리플라이트 보고서, 표준 중심 검증을 소스 코드 컴포넌트로 구현할 수 있습니다.

이 글은 teams sharing PDF viewing code between Delphi, Lazarus, and Free Pascal applications을 위한 글입니다. Lazarus and Free Pascal viewer integration을 단순한 컴포넌트 호출이 아니라 운영 환경의 문서 엔지니어링으로 다룹니다.

실제 위험은 a viewer can compile in multiple IDEs yet fail in deployment because widget-set behavior, binary loading, calling conventions, and resource paths differ입니다. 따라서 명확한 계약, 관찰 가능한 진단, 실제 고객 파일을 반영한 회귀 샘플이 필요합니다.

아키텍처 결정

Treat the viewer layer as portable infrastructure. supported IDEs, compiler versions, CPU architectures, and widget sets / PDFium binary location, bitness, load failure message, and update policy

  • supported IDEs, compiler versions, CPU architectures, and widget sets
  • PDFium binary location, bitness, load failure message, and update policy
  • high-DPI scaling, mouse wheel, keyboard, and focus behavior across frameworks
  • feature parity expectations for thumbnails, search, forms, printing, and annotations

구현 흐름

Stabilize runtime loading before adding UI features. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. create a small viewer shell that loads the PDFium runtime before opening documents
  2. normalize paths and binary names for each supported deployment layout
  3. exercise zoom, scroll, selection, and focus events on every widget set
  4. separate shared PDF logic from framework-specific panels and dialogs
  5. package diagnostics that identify missing binaries and architecture mismatches

검증 증거

Deployment evidence for mixed-toolchain support. Keep these fields with the output or support record.

  • compiler, widget set, target architecture, PDFium binary path, and runtime version
  • load success or failure reason before the first document is opened
  • input-event test results for wheel, drag, keyboard, focus, and high-DPI scaling
  • feature matrix showing which viewer actions are supported in each build

Portability is a packaging decision

A Lazarus and FPC integration should define how the PDFium binary is found, which widget sets are supported, how DPI and input events are normalized, and which viewer features are guaranteed across platforms.

Operational metrics to watch

The first release should expose enough metrics to prove the workflow is healthy under real files, not only under curated samples.

  • count and rate for compiler, widget set, target architecture, PDFium binary path, and runtime version
  • warning trend for a 32-bit application cannot load a 64-bit PDFium binary
  • latency of the stage that must create a small viewer shell that loads the PDFium runtime before opening documents
  • profile usage for supported IDEs, compiler versions, CPU architectures, and widget sets

Lazarus and Free Pascal viewer integration에 대한 엔지니어링 검토 노트

이 검토 노트를 사용해 기능이 데모 단계를 넘어섰고 출시, 지원, 고객 에스컬레이션 상황에서 설명할 수 있는지 확인합니다

  • 결정: supported IDEs, compiler versions, CPU architectures, and widget sets. 구현상 핵심 지점: normalize paths and binary names for each supported deployment layout. 승인 증거: input-event test results for wheel, drag, keyboard, focus, and high-DPI scaling. 회귀 트리거: printing and file dialogs may need framework-specific wrappers
  • 결정: PDFium binary location, bitness, load failure message, and update policy. 구현상 핵심 지점: exercise zoom, scroll, selection, and focus events on every widget set. 승인 증거: feature matrix showing which viewer actions are supported in each build. 회귀 트리거: a 32-bit application cannot load a 64-bit PDFium binary
  • 결정: high-DPI scaling, mouse wheel, keyboard, and focus behavior across frameworks. 구현상 핵심 지점: separate shared PDF logic from framework-specific panels and dialogs. 승인 증거: compiler, widget set, target architecture, PDFium binary path, and runtime version. 회귀 트리거: relative paths often work in the IDE and fail from installed shortcuts

경계 사례

  • a 32-bit application cannot load a 64-bit PDFium binary
  • relative paths often work in the IDE and fail from installed shortcuts
  • widget-set differences can alter focus behavior in docked panes
  • printing and file dialogs may need framework-specific wrappers

Delphi / C++Builder 참고 사항

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. 중요한 용어는 Lazarus, Free Pascal, LCL, PDFium, widget set, runtime loading.

Delphi 코드 예제

다음 Delphi 스케치는 이 주제에 맞는 실무형 서비스 경계를 보여 줍니다. 정책 검사, 로깅, 검증을 좁은 제품 호출 구간 밖에 두면 워크플로를 테스트하기 쉽습니다.

procedure TMainForm.OpenDocument(const FileName: string);
begin
  PdfView.LoadFromFile(FileName);
  TrackDocumentLifetime(FileName, PdfView.PageCount);
  PageSpinEdit.MaxValue := PdfView.PageCount;
  RenderCurrentPage;
  UpdateToolbarState;
end;

운영 체크리스트

  • 워크플로는 빈 파일, 일반 고객 파일, 최악의 파일에서 실행합니다
  • 생성된 PDF는 대상 뷰어, 검증기, 프린터 또는 downstream 애플리케이션에서 엽니다
  • 제품 버전, 프로필 버전, 입력 해시, 출력 경로, 경과 시간, 경고 수를 기록합니다
  • 암호, 인증서, 임시 파일, 고객 데이터는 명확한 보존 규칙에 따라 관리합니다
  • 고객 파일이 새로운 경계 사례를 드러내면 회귀 문서를 추가합니다

제품 문서

PDFium Component

추가 코드 예제

procedure TViewerForm.FormCreate(Sender: TObject);
begin
  Pdf := TPdf.Create(Self);

  PdfView := TPdfView.Create(Self);
  PdfView.Parent := Self;
  PdfView.Align := alClient;
  PdfView.Pdf := Pdf;
  PdfView.FitMode := pfmFitWidth;

  if ParamCount > 0 then
  begin
    Pdf.FileName := ParamStr(1);
    Pdf.Active := True;   // opens the document; PageCount valid after this
  end;
end;