Usando os exemplos da página do ChilKat, para fox pro, adaptei para me extended com harbour, mas está dando erro de método não exportado na linha:
lnSuccess:= loPdf:LoadFile([E:\tools\newpcmso\chilkat\teste.pdf])
obs: existe o arquivo nesta pasta
/*****************************************************************************
* SISTEMA : ROTINA EVENTUAL *
* PROGRAMA : DEMO.PRG *
* OBJETIVO : Assinar Digitalmente um Pdf *
* AUTOR : Marcelo Antonio Lázzaro Carli *
* DATA : 22.04.2021 *
* ULT. ALT.: 22.04.2021 *
*****************************************************************************/
#include <minigui.ch>
Function Main()
REQUEST HB_LANG_PT
HB_LangSelect([PT])
REQUEST HB_CODEPAGE_PT850 &&& PARA INDEXAR CAMPOS ACENTUADOS
HB_SETCODEPAGE([PT850]) &&& PARA INDEXAR CAMPOS ACENTUADOS
Set wrap on
Set talk off
Set date briti &&& data no formato dd/mm/aaaa
Set dele on &&& ignora registros marcados por deleção
Set score off
Set exact on
Set ToolTip on
Setcancel(.F.) &&& evitar cancelar sistema c/ ALT + C
Set cent on &&& ano com 4 dígitos
Set epoch to 2000 &&& ano a partir de 2000
Set excl off &&& abre arquivos em modo compartilhado
Set navigation extended &&& enter no lugar do tab
Set language to portuguese &&& mensagens em português
Set multiple off warning &&& abrir 1 cópia somente
Set tooltipstyle balloon &&& para mensagem dos campos em forma de balão
Set menustyle extended &&& padrão é standard, extended estilo office 2007
Set programmaticchange off &&& introduzida na build 1.9.94
Define window main at 0, 0 width getDesktopWidth() height getDesktopHeight() ICON "dw.ico" NOTIFYICON "dw.ico" MAIN title [Atualizador] NOSIZE
@ 030,090 BUTTON btn_P1 caption [&Assinar] action {|| (fAssinar(), main.Release())} WIDTH 120 TOOLTIP [Selecione]
on key escape action {|| Thiswindow.Release()}
end window
main.Center
main.maximize
main.Activate
Return (Nil)
Static Procedure fAssinar()
Local loPdf, lnSuccess, loJson, loCert
Destravar()
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* loPdf = CreateObject('Chilkat_9_5_0.Pdf')
loPdf:= win_OleGetActiveObject([Chilkat_9_5_0.Pdf])
* Load a PDF to be signed.
* The "hello.pdf" is available at https://chilkatsoft.com/hello.pdf
lnSuccess:= loPdf:LoadFile([E:\tools\newpcmso\chilkat\teste.pdf])
If lnSuccess == 0
MsgInfo(loPdf:LastErrorText, [este])
RELEASE loPdf
CANCEL
Endif
loJson:= win_OleCreateObject([Chilkat_9_5_0.JsonObject])
* Put the signature on page 1, top left
loJson:UpdateInt([page],1)
loJson:UpdateString([appearance.y],[top])
loJson:UpdateString([appearance.x],[left])
* Use a font scale of 10.0
loJson:UpdateString([appearance.fontScale],[10.0])
* In this example, the appearance of the digital signature will contain three lines:
* 1) The signing certificate's common name
* 2) The current date/time
* 3) Some arbitrary text.
* The keyword "cert_cn" is replaced with the Certificate's Subject Common Name.
* The keyword "current_dt" is replaced with the current date/time.
* Any number of appearance text lines can be added.
loJson:UpdateString('appearance.text[0]',[Digitally signed by: cert_cn])
loJson:UpdateString('appearance.text[1]',[current_dt])
loJson:UpdateString('appearance.text[2]',[The crazy brown fox jumps over the lazy dog.])
* Load the signing certificate. (Use your own certificate.)
loCert:= win_OleCreateObject([Chilkat_9_5_0.Cert])
lnSuccess:= loCert:LoadPfxFile("qa_data/pfx/myPdfSigningCert.pfx],[secret])
If lnSuccess == 0
MsgInfo(loCert:LastErrorText, [este 1])
RELEASE loPdf
RELEASE loJson
RELEASE loCert
CANCEL
Endif
* Tell the pdf object to use the certificate for signing.
lnSuccess:= loPdf:SetSigningCert(loCert)
If lnSuccess == 0
MsgInfo(loPdf:LastErrorText, [este 2])
RELEASE loPdf
RELEASE loJson
RELEASE loCert
CANCEL
Endif
lnSuccess:= loPdf:SignPdf(loJson,[hello_signed.pdf])
If lnSuccess == 0
MsgInfo(loPdf:LastErrorText, [este 3])
RELEASE loPdf
RELEASE loJson
RELEASE loCert
CANCEL
Endif
MsgInfo([The PDF has been successfully cryptographically signed.], [Finalmente])
Return (Nil)
Static Function Destravar()
Local loGlob:= win_OleCreateObject([Chilkat_9_5_0.Global]), lnSuccess, lnStatus
lnSuccess:= loGlob:UnlockBundle([Start my 30-day Trial])
If lnSuccess <> 1
MsgInfo(loGlob:LastErrorText, [aqui])
RELEASE loGlob
CANCEL
Endif
lnStatus:= loGlob:UnlockStatus
If lnStatus == 2
MsgInfo([Desbloqueado. Usando o código de desbloqueio comprado.], [aqui 1])
Else
MsgInfo([Desbloqueado no modo de teste.], [aqui 2])
Endif
* The LastErrorText can be examined in the success case to see if it was unlocked in trial more, or with a purchased unlock code.
* MsgInfo(loGlob:LastErrorText, [aqui 3])
RELEASE loGlob
Return (Nil)