API referencePDF/A & Conformance

pdfAddFileComment

pdfAddFileComment appends a free-text comment line to a

C
BOOL32 __stdcall pdfAddFileCommentA(PPDF IPDF, const char* AText);
BOOL32 __stdcall pdfAddFileCommentW(PPDF IPDF, const wchar_t* AText);
BOOL32 __stdcall pdfAssociateEmbFile(PPDF IPDF, TAFDestObject DestObject, int32_t DestHandle, TAFRelationship Relationship, uint32_t EmbFile);
Delphi
function pdfAddFileCommentA(const IPDF: PPDF; const AText: PAnsiChar): LongBool; stdcall;
function pdfAddFileCommentW(const IPDF: PPDF; const AText: PWideChar): LongBool; stdcall;
function pdfAssociateEmbFile(const IPDF: PPDF; DestObject: TAFDestObject; DestHandle: Integer; Relationship: TAFRelationship; EmbFile: Cardinal): LongBool; stdcall;

Purpose. pdfAddFileComment appends a free-text comment line to a list retained on the document (its consumer/serialization target wasn't traced further in this chapter — presumably surfaced somewhere in file metadata or a debug/log export). pdfAssociateEmbFile sets an embedded file's /AFRelationship — the ZUGFeRD/Factur-X-style "this embedded file's role relative to the document" tag (Data, Source, Alternative, etc.).

Description. pdfAddFileCommentA/W use inconsistent string encodings: A narrows via plain AnsiString, W encodes as UTF-8 (RawByteString(UTF8Encode(...))) — not the system codepage AnsiString conversion the A/W pairing convention elsewhere in this SDK would suggest; a comment round-tripped through W and later read back assuming ANSI encoding would be corrupted for non-ASCII text. MAJOR — pdfAssociateEmbFile's DestObject and DestHandle parameters are both accepted by the ABI but completely unused by the real implementation — despite strongly implying "associate this embedded file with a specific destination object" (a page, an annotation, the document catalog — the standard PDF /AF associated-file mechanism's actual purpose), the real method only ever sets a single, object-independent relationship-type string on the embedded file itself (FEmbAFRel[EmbFile-1] := RelName[Relationship]) — there is no real per-destination-object association happening at all, only a document-wide relationship label per embedded file.

Parameters.

ParameterDescription
IPDFDocument handle.
ATextComment text; A = ANSI codepage, W = UTF-8 (inconsistent with each other).
DestObject, DestHandleAccepted but completely unused — no real per-object association occurs.
RelationshipThe relationship-type tag actually applied (document-wide per embedded file, not per destination).
EmbFileTarget embedded-file handle (must already exist, 1..FEmbCount).

Return value. True on success (AddFileComment: non-empty text; AssociateEmbFile: valid EmbFile and in-range Relationship).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
PDF/A & Conformance
Category

Content Creation

Exported names

pdfAddFileCommentA pdfAddFileCommentW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.