GetStringListItem
Miscellaneous functions
Description
Returns the string at position ItemIndex in the string list identified by StringListID. String lists are produced by other API functions — most commonly CheckFileCompliance, which returns one entry per detected compliance issue.
Syntax
Delphi
function TPDFlib.GetStringListItem(StringListID, ItemIndex: Integer): WideString;ActiveX
Function PDFlib::GetStringListItem(StringListID As Long, ItemIndex As Long) As StringDLL
wchar_t * DLGetStringListItem(int InstanceID, int StringListID, int ItemIndex);Parameters
| StringListID | The ID of the string list as returned by a producer function such as CheckFileCompliance. |
|---|---|
| ItemIndex | The one-based index of the item to retrieve. The first item is 1; the last item is GetStringListCount(StringListID). Out-of-range indices return an empty string. |
Return value
The string at the requested index, or an empty string if StringListID is invalid or ItemIndex is outside [1 .. GetStringListCount].
Remarks
For lists produced by CheckFileCompliance the item format is CODE: human-readable description, where CODE is one of the five-digit issue codes documented on the CheckFileCompliance page (00002, 00003, 00005, 00006, 00007, 00011, 00012). Strip the prefix before the colon to act on the code programmatically.
Example
// Parse the issue code from each compliance issue line
var
Issues, Count, I, ColonPos: Integer;
Line, Code: WideString;
begin
Issues := PDF.CheckFileCompliance('archive.pdf', '', 1, 0);
if Issues = 0 then Exit;
Count := PDF.GetStringListCount(Issues);
for I := 1 to Count do
begin
Line := PDF.GetStringListItem(Issues, I);
ColonPos := Pos(':', Line);
if ColonPos > 0 then
Code := Trim(Copy(Line, 1, ColonPos - 1))
else
Code := Line;
if Code = '00006' then
WriteLn('Document is encrypted — cannot be PDF/A')
else
WriteLn('Issue ', Code, ': ', Line);
end;
PDF.ReleaseStringList(Issues);
end;