Set and get additional properties

<< Click to Display Table of Contents >>

Navigation:  Commands >

Set and get additional properties

When you need WPViewPDF to reurn a string value, the usual way is to call a "get" command first which returns the required buffer length. Then this commands can be used to fill a prepared buffer with the data:

 

COMPDF_GetTextBuf  = 261

Read ANSI buffer.

 

COMPDF_GetTextBufW  = 263

Read unicode buffer.

 

The WPViewPDF implements the utility functions CommandGetStr and CommandGetStrA to simplify the task:

 

Read unicode string:

function TWPViewPDF.CommandGetStr(command: Integer; str: String;

  Param: Cardinal): WideString;

var

  i: Integer;

begin

  i := CommandStrEx(command, str, Param);

  if i > 0 then

  begin

    SetLength(Result, i);

    CommandEx(COMPDF_GetTextBufW, Cardinal(@Result[1]));

  end

  else

    Result := '';

end;

 

Read ANSI string:

function TWPViewPDF.CommandGetStrA(command: Integer; str: String;

  Param: Cardinal): AnsiString;

var

  i: Integer;

begin

  i := CommandStrEx(command, str, Param);

  if i > 0 then

  begin

    SetLength(Result, i);

    CommandEx(COMPDF_GetTextBuf, Cardinal(@Result[1]));

  end

  else

    Result := '';

end;

 

 

COMPDF_GetInfoItemsLen = 264

 

This command is used to read the info items of the PDF as string list. The items will be comma separated.

You first need to call COMPDF_GetInfoItemsLen to get the required buffer length, and then COMPDF_GetTextBuf to read the actual text.

 

COMPDF_GetInfoItemsLenW = 265

 

Works like COMPDF_GetInfoItemsLen but creates a unicode string. Use COMPDF_GetTextBufW to read the text.

 

When you use WPViewPDF PLUS You can also set the info items:

 

COMPDF_SetString  = 502 - Set info entry name=text

COMPDF_SetTitle   = 503 - Set title info string

COMPDF_SetSubject = 504 - Set subject info string

COMPDF_SetAuthor  = 505 - Set author info string

COMPDF_SetKeywords= 506 - Set keywords info string