기술 문서

PDFium Component: Delphi에서 secure PDF preview surfaces

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

이 글은 teams showing sensitive PDFs inside line-of-business applications without granting full document-control features을 위한 글입니다. secure PDF preview surfaces을 단순한 컴포넌트 호출이 아니라 운영 환경의 문서 엔지니어링으로 다룹니다.

실제 위험은 a preview window can accidentally become a data-exfiltration surface if printing, saving, clipboard, links, attachments, and temporary files are not governed입니다. 따라서 명확한 계약, 관찰 가능한 진단, 실제 고객 파일을 반영한 회귀 샘플이 필요합니다.

아키텍처 결정

Treat preview as a permissioned operation. which roles can open, print, save, copy, search, annotate, or follow links / temporary file location, lifetime, naming, encryption, and cleanup policy

  • which roles can open, print, save, copy, search, annotate, or follow links
  • temporary file location, lifetime, naming, encryption, and cleanup policy
  • external link, embedded file, JavaScript, and attachment handling
  • audit events required for open, close, denied action, print, and export attempts

구현 흐름

Disable features by policy rather than hiding buttons. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. resolve the user's preview policy before the PDF is loaded
  2. open the document through a controlled stream or temporary file boundary
  3. disable and audit denied actions at the command layer, not only in visible buttons
  4. handle links, attachments, and scripts according to the preview profile
  5. clean temporary resources and write a session summary when the viewer closes

검증 증거

Security evidence for preview sessions. Keep these fields with the output or support record.

  • user role, document classification, preview profile, and allowed action list
  • denied commands, external target attempts, attachment attempts, and print requests
  • temporary file path or stream mode plus cleanup result
  • session duration, pages viewed when policy requires it, and close reason

Read-only UI is not the same as secure preview

Secure preview combines viewer permissions, application roles, document policy, link handling, attachment policy, temp-file control, and audit logging. The PDF renderer is only one layer of that surface.

Customer-visible behavior

Users do not see internal call order. They see whether the file opens, validates, prints, edits, imports, or gets rejected. The workflow should translate secure PDF preview surfaces results into states users can act on.

  • resolve the user's preview policy before the PDF is loaded
  • open the document through a controlled stream or temporary file boundary
  • disable and audit denied actions at the command layer, not only in visible buttons
  • keyboard shortcuts and context menus can bypass toolbar-only restrictions
  • attachments and links may leak data even when save is disabled

secure PDF preview surfaces에 대한 엔지니어링 검토 노트

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

  • 결정: which roles can open, print, save, copy, search, annotate, or follow links. 구현상 핵심 지점: open the document through a controlled stream or temporary file boundary. 승인 증거: temporary file path or stream mode plus cleanup result. 회귀 트리거: watermarks should supplement policy but should not be the only protection
  • 결정: temporary file location, lifetime, naming, encryption, and cleanup policy. 구현상 핵심 지점: disable and audit denied actions at the command layer, not only in visible buttons. 승인 증거: session duration, pages viewed when policy requires it, and close reason. 회귀 트리거: keyboard shortcuts and context menus can bypass toolbar-only restrictions

경계 사례

  • keyboard shortcuts and context menus can bypass toolbar-only restrictions
  • attachments and links may leak data even when save is disabled
  • temporary preview files can remain recoverable if cleanup is not verified
  • watermarks should supplement policy but should not be the only protection

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. 중요한 용어는 secure preview, read-only viewer, audit log, temporary file, attachments, policy.

Delphi 코드 예제

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

procedure TSecurePreview.OpenReadOnly(const FileName: string);
begin
  RequireAllowedLocation(FileName);
  PdfView.LoadFromFile(FileName);
  DisableSaveAndClipboardCommands;
  RenderWatermarkedPage(1, CurrentUserName);
  LogPreviewSession(FileName, PdfView.PageCount);
end;

운영 체크리스트

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

제품 문서

PDFium Component

추가 코드 예제

procedure TPreviewPane.PdfViewWebLinkClick(Sender: TObject;
  const Url: WString; var Handled: Boolean);
begin
  Handled := True;   // never fall through to the default shell behavior

  if (AnsiStartsText('https://', Url) or AnsiStartsText('http://', Url))
    and HostIsAllowed(Url) then
    OpenInBrowser(Url)
  else
    FAudit.LogBlockedLink(FDocumentId, Url);
end;
procedure TPreviewPane.ExportAttachment(Index: Integer; const TargetDir: string);
var
  RawName, SafeName, Ext: string;
  Data: TBytes;
begin
  RawName := string(Pdf.AttachmentName[Index]);
  SafeName := ExtractFileName(RawName);    // strips any path components
  Ext := LowerCase(ExtractFileExt(SafeName));

  if not FAllowedExt.Contains(Ext) then    // allowlist, not blocklist
    raise EPreviewPolicy.CreateFmt('Attachment type %s blocked by policy', [Ext]);

  Data := Pdf.Attachment[Index];           // embedded payload as raw bytes
  TFile.WriteAllBytes(
    IncludeTrailingPathDelimiter(TargetDir) + SafeName, Data);
end;