setPasswords Method

Sets passwords for PDF and Word document protection.

PDF
Object.setPasswords(tcOwnerPassword [, tcUserPassword])
MS Word
Object.setPasswords(tcReadPassword [, tcWritePassword [, tlRequirePassword]])

Parameters

tcOwnerPassword

 Owner password. If the owner password is empty, a random string will be generated as the password. The owner can do anything with the document.

tcUserPassword 

 The user password can be empty. The user permissions can be set using the setPermissions()  methods.

tcReadPassword

 Password for openning and reading document. Can be empty.

tcWritePassword 

 Password for openning, reading  document and writes changes. Can be empty.

tlRequirePassword

 If set to .T., Word will ask for the password even when the document is being opened first time after the generation (if DoNotOpenViewer property is set to .F.). Default value is .F.

Remarks

Applies To: XFRX#INIT, XFRX#LISTENERPDF#READERPDFL#INIT, oXFRX

XFRX version: 24.0 for oXFRX

Examples

PDF
LOCAL m.lnErr
m.loXFRX=EVALUATE([xfrx("XFRX#INIT")])
m.loXFRX.setPasswords('ownerpwd')

m.lnErr=m.loXFRX.SetParams(,,,,.T.,,"PDF")
IF m.lnErr<>0
   ?m.loXFRX.ErrorMessage(m.lnErr)
ELSE
ENDIF
MS Word
LOCAL m.lnErr
m.loXFRX=EVALUATE([xfrx("XFRX#INIT")])
m.loXFRX.setPasswords('readpassword')

m.lnErr=m.loXFRX.SetParams(,,,,.T.,,"FDOC")
IF m.lnErr<>0
   ?m.loXFRX.ErrorMessage(m.lnErr)
ELSE
ENDIF
PDF#READER
m.loPDFR = EVALUATE([xfrx("PDF#READER")])
m.loPDFR.SetPasswords("owner","user") && set password for pdf file
m.lcFile="BASE-UNI.pdf"
IF m.loPDFR.openDocument(m.lcFile) < 0 
   RETURN
ENDIF
m.lnError=m.loPDFR.ReadDocument()

SELE (m.loPDFR.cCursorName)
BROWSE NORMAL
 
m.loPDFR.closeDocument()