PDFium Delphi Component Docs

AttachmentName 속성

컴포넌트: TPdf  ·  유닛: PDFium
document EmbeddedFiles name tree의 지정한 0 기반 인덱스에 있는 embedded file로 등록된 Unicode file name을 반환합니다

Syntax

property AttachmentName[Index: Integer]: WString; // read only

Description

모든 PDF 파일 첨부는 파일 스펙 딕셔너리에 파일 이름을 갖고 있습니다 — 보통 작성자 디스크에 있던 원래 이름(예: contract.docx, source-data.csv)입니다. AttachmentName은 그 이름을 WString으로 노출하므로 UI에 표시하거나 저장 경로 제안에 쓰거나 확장자로 분류할 수 있습니다

반환 문자열은 PDF의 UTF-16BE 또는 PDFDocEncoding 저장소에서 디코딩되므로 ASCII가 아닌 이름(중국어, 키릴 문자, 악센트 있는 라틴 문자)도 그대로 왕복합니다. 작성자가 명시적인 /F나 /UF 파일 이름 없이 키 항목만 남긴 경우에는 빈 문자열을 반환합니다

이 프로퍼티는 읽기 전용입니다. 첨부 이름 바꾸기는 이 API에서 지원하지 않으니, 파일 이름을 바꿔야 한다면 DeleteAttachment로 슬롯을 지우고 CreateAttachment로 다시 만든 뒤 Attachment로 바이트를 다시 넣으세요

Parameters

IndexInteger. 첨부의 0 기반 위치입니다. [0, AttachmentCount - 1] 범위 안이어야 합니다. 범위를 벗어난 인덱스를 넘기면 빈 문자열을 반환합니다

Remarks

Example

var
  I: Integer;
  FileName: string;
begin
  Pdf1.LoadFromFile('package.pdf');
  ListBox1.Items.BeginUpdate;
  try
    ListBox1.Items.Clear;
    for I := 0 to Pdf1.AttachmentCount - 1 do
    begin
      FileName := Pdf1.AttachmentName[I];
      if FileName = '' then
        FileName := Format('(unnamed #%d)', [I]);
      ListBox1.Items.AddObject(FileName, TObject(I));
    end;
  finally
    ListBox1.Items.EndUpdate;
  end;
end;

See Also

Attachment, AttachmentCount, AttachmentType, CreateAttachment, DeleteAttachment