GetStringListCount

杂项函数

描述

返回由另一 API 函数创建的字符串列表中存储的字符串数量,最常见的产生者是 CheckFileCompliance,它返回非零 StringListID,其条目列出已验证文档中发现的合规问题

语法

Delphi

Function TPDFlib.GetStringListCount(StringListID: Integer): Integer;

ActiveX

Function PDFlib::GetStringListCount(StringListID As Long) As Long

DLL

int DLGetStringListCount(int InstanceID, int StringListID);

参数

StringListID由 CheckFileCompliance 等生成函数返回的字符串列表 ID,必须引用当前 PDFlib 实例拥有的字符串列表

返回值

0列表为空,或 StringListID 未引用此实例拥有的有效字符串列表
> 0列表中当前的字符串数量

备注

返回的计数是 ItemIndex 参数的上限,适用于 GetStringListItem:有效索引为 1 至 GetStringListCount(StringListID),含两端。项目不从零开始编号

字符串列表由生成它们的 PDFlib 实例拥有,并会在实例销毁时自动释放。如果希望更早释放列表,请调用 ReleaseStringList,例如在连续验证许多文件的长时间运行进程中

示例

// Enumerate every compliance issue reported by CheckFileCompliance
var
  Issues, Count, I: Integer;
begin
  Issues := PDF.CheckFileCompliance('output.pdf', '', 1, 0);
  if Issues <> 0 then
  begin
    Count := PDF.GetStringListCount(Issues);
    for I := 1 to Count do
      WriteLn(PDF.GetStringListItem(Issues, I));
    PDF.ReleaseStringList(Issues);
  end;
end;

另请参阅

GetStringListItem、ReleaseStringList、CheckFileCompliance