Página 2 de 3

Assinatura digital ??

Enviado: 19 Abr 2021 11:51
por JoséQuintas
Achei este documento, mas não guardei o link, de uma universidade.
No final tem um fonte em NET pra assinatura.
À primeira vista, usa o Adobe, igual costumamos usar o CreateObject( "Excel.Application" ), mas usando do Adobe.
AssinaturaPDF.pdf
(1.92 MiB) Baixado 102 vezes
Nota: é que fiz outras pesquisas em seguida, e acabei perdendo o link

Assinatura digital ??

Enviado: 19 Abr 2021 11:53
por JoséQuintas

Assinatura digital ??

Enviado: 19 Abr 2021 12:05
por toninhofwi
Marcelo, Free não tem mas o pagamento é único, é uma DLL activeX com toneladas de exemplos em foxPro que basicamente a única diferença é que no Fox se usa obj.method e no Harbour obj:method,

Exemplos de como assinar um PDF estão aqui:

https://www.example-code.com/foxpro/pdf_signatures.asp

Assinatura digital ??

Enviado: 19 Abr 2021 14:07
por malcarli
Obrigado, vou testar com o demo de 30 dias, ver ser consigo fazer rodar um exemplo. Se der certo o exemplo, posto o fonte aqui.

toninhofwi escreveu:Marcelo, Free não tem mas o pagamento é único, é uma DLL activeX com toneladas de exemplos em foxPro que basicamente a única diferença é que no Fox se usa obj.method e no Harbour obj:method,

Exemplos de como assinar um PDF estão aqui:

https://www.example-code.com/foxpro/pdf_signatures.asp
Att.

Marcelo A. L. Carli
Marília/SP
Capital Nacional do Alimento ®

https://malc-informatica.ueniweb.com
http://marcelo.lx.com.br
Email / Skype: malcarli@life.com.br

Assinatura digital ??

Enviado: 19 Abr 2021 14:10
por malcarli
O que meus clientes estão fazendo é exatamente isto, mas querem que eu automatize
JoséQuintas escreveu:Ok tava no histórico do Edge.

http://www.sef.sc.gov.br/arquivos_porta ... em_PDF.pdf

Quanto a esta rotina, parece uma solução viável, o problema que não entendo nada de .Net, se conseguir uma "tradução" para harbour, daria para testar.


Att.

Marcelo A. L. Carli
Marília/SP
Capital Nacional do Alimento ®

https://malc-informatica.ueniweb.com
http://marcelo.lx.com.br
Email / Skype: malcarli@life.com.br

Assinatura digital ??

Enviado: 20 Abr 2021 16:14
por toninhofwi
Segue um teste simples para ler algumas TAGs da NFe, para ajudar a compreeender o jeito de trabalho da DLL porque tudo nela segue esta regra:

---cut---

Código: Selecionar todos

static procedure testChilkat()

   local oGlobal := win_OleGetActiveObject( "Chilkat_9_5_0.Global.1" )

   local oXml

   if !hb_IsObject( oGlobal )
      oGlobal = win_OleCreateObject( "Chilkat_9_5_0.Global.1" )
   endif

   if hb_IsObject( oGlobal )

      if oGlobal:UnlockBundle( "Start my 30-day Trial" ) == 1

         oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" )

         if !hb_IsObject( oXml )
            oXml = win_OleCreateObject( "Chilkat_9_5_0.Xml" )
         endif

         if hb_IsObject( oXml )

            oXml:LoadXmlFile( "d:\xml\n1.xml" )

            ? oXml:GetChildContent( "protNFe|infProt|chNFe" )

            ? oXml:GetChildContent( "NFe|infNFe|infAdic|infCpl" )

         endif

      endif

   endif

return
---cut---

Assinatura digital ??

Enviado: 22 Abr 2021 08:46
por malcarli
Bom dia, neste exemplo abaixo onde está oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" ), substituiria pela extensão pdf?

toninhofwi escreveu:Segue um teste simples para ler algumas TAGs da NFe, para ajudar a compreeender o jeito de trabalho da DLL porque tudo nela segue esta regra:

---cut---

Código: Selecionar todos

static procedure testChilkat()

   local oGlobal := win_OleGetActiveObject( "Chilkat_9_5_0.Global.1" )

   local oXml

   if !hb_IsObject( oGlobal )
      oGlobal = win_OleCreateObject( "Chilkat_9_5_0.Global.1" )
   endif

   if hb_IsObject( oGlobal )

      if oGlobal:UnlockBundle( "Start my 30-day Trial" ) == 1

         oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" )

         if !hb_IsObject( oXml )
            oXml = win_OleCreateObject( "Chilkat_9_5_0.Xml" )
         endif

         if hb_IsObject( oXml )

            oXml:LoadXmlFile( "d:\xml\n1.xml" )

            ? oXml:GetChildContent( "protNFe|infProt|chNFe" )

            ? oXml:GetChildContent( "NFe|infNFe|infAdic|infCpl" )

         endif

      endif

   endif

return
---cut---

Assinatura digital ??

Enviado: 22 Abr 2021 13:21
por toninhofwi
Bom dia, neste exemplo abaixo onde está oXml = win_OleGetActiveObject( "Chilkat_9_5_0.Xml" ), substituiria pela extensão pdf?
Boa tarde,

Não, eu só dei o exemplo de como se utiliza a chilkat, criei um exemplo onde eu leio algumas tags da NFe.

Para assinar PDF você terá que estudar os exemplos em FOX pro que tem no site da chilkat e adaptar o código.

Abraço.

Assinatura digital ??

Enviado: 22 Abr 2021 16:33
por malcarli
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

Código: Selecionar todos

/*****************************************************************************
 * 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)


Assinatura digital ??

Enviado: 23 Abr 2021 12:15
por malcarli
Boa tarde, testando a versão 9.5.0.86 da Chilkat, funcionou perfeitamente a assinatura do pdf. Nas versões anteriores não existe o comando loadfile, por isso do erro de método não exportado. Fiz teste usando a chave de versão trial.

Agora convencer clientes a pagar pela biblioteca, ou continuar buscando uma solução free.

Assinatura digital ??

Enviado: 04 Mai 2021 08:09
por Itamar M. Lins Jr.
Olá!
JsignPdf is an excellent tool for Signing PDF documents. In windows , it can be used with WINDOWS-MY key store or other key stores.

1.Create PDF using hbhpdf contrib
2. Sign using JsignPdf in Java JAR (wapi_shellexecute () in silent mode with bundles of JsignPdf parameters)
(can be done from within your Harbour application , JsignPdf is a compact & free java program from Josef Cacek)

Shaji Thomas
Achei pertinente ao assunto.

Saudações,
Itamar M. Lins Jr.

Assinatura digital ??

Enviado: 04 Mai 2021 18:07
por Mario Mesquita
Boa noite a todos.

Itamar, dá pra usar com Harbour? Não entendi bem, são rotinas em Java? Se pode embarcar no Harbour, onde se pode obter mais detalhes?

Sds,
Mario.

Assinatura digital ??

Enviado: 04 Mai 2021 18:29
por Itamar M. Lins Jr.
Olá!
dá pra usar com Harbour?
O autor disse que usa com o Harbour, mas não colocou os comandos.

Pelo que ele escreveu ai, não deve ser complicado.
Com uma rápida procura pelo google, achei isso!
https://arwsd.com.br/download/manuais/M ... ignPDF.pdf

Saudações,
Itamar M. Lins Jr.

Assinatura digital ??

Enviado: 04 Mai 2021 18:39
por Itamar M. Lins Jr.
Olá!
Estou no Linux, depois que baixar o aquivo jSignpdf.jar teste ai:

Código: Selecionar todos

java -jar JSignPdf.jar -kst PKCS12 -ksf my_certificate.pfx -ksp myPrivateKeystorePassword -d C:\output C:\Documents\*.pdf

Used options:
-kst keystore type
-ksf path to a keystore
-ksp password
-d output folder
Saudações,
Itamar M. Lins Jr.

Assinatura digital ??

Enviado: 14 Ago 2023 15:44
por clodoaldomonteiro
Boa tarde,

Reacendendo este Post, vcs conseguiram assinar com A3, onde temos que plugar o PenDriver ou Card, e ainda digitar a senha do responsável?

Desde já, agradeço.