property AttachmentCount: Integer; // read only
AttachmentCount は catalog の /Names /EmbeddedFiles name tree からたどれる embedded file stream を列挙します (PDF 1.7 spec section 7.11)。これらは PDF 内に格納された任意の file (XML, spreadsheet, source CAD, signed XML, ZIP archives など) で、viewer では “Attachments” sidebar として表示されます。PDF/A-3 では、長期再現性のために関連する source artefact をすべてこの方法で embedded にする必要があります
値は Active が False のときと、文書に embedded file がないときに 0 になります。file-attachment annotations (subtype /FileAttachment) はここでは 数えません。それらは page-level annotation であり、代わりに AnnotationCount から見えます。PDFiumPas は Attachment[Index] を通じて embedded stream を TBytes として公開し、人が読める file name と MIME-style type は AttachmentName[Index] と AttachmentType[Index] で取得できます
典型的な loop は for I := 0 to Pdf.AttachmentCount - 1 do です。Attachment[I] の各 access は embedded file stream を memory に decompress するので、disk に書き出したり parser に渡したりするなら TBytes を cache してください。attachment の追加・削除は index を無効にします。変更後は AttachmentCount を再取得してください
FeatureSupported(feAttachment) と組み合わせると、installed PDFium build が attachment name の変更をサポートしているか判定できます
var I: Integer;
var Data: TBytes;
for I := 0 to Pdf1.AttachmentCount - 1 do
begin
Data := Pdf1.Attachment[I];
TFile.WriteAllBytes(Pdf1.AttachmentName[I], Data);
end;