FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Se podrá leer el texto de un PDF y guardar algunos datos ?
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Wed Jun 05, 2013 03:44 AM

Hola

No se si se pueda leer ciertos datos del texto de un PDF para guardarlos en una base de datos

Saluditos :wink:

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Wed Jun 05, 2013 04:19 AM
Try this. I found it in this forum.
The code expects OpenOffice to be installed on the PC

Code (fw): Select all Collapse
**============================================================================**
** Author....: José Maria da Silva                                             **
** Purpose : Read a PDF, extract text and display on browse, save as TXT.      **
** Pre-Requirement: Must have OpenOffice/Broffice installed on the PC          **
**=============================================================================**

#INCLUDE "FIVEWIN.CH"
#include "xbrowse.ch"


//------------------------//
FUNCTION MAIN()

    LOCAL oService,oDesktop,oDoc,oShape,oCursor,oDrawPage,aProp:={},i
    LOCAL cFile,cText,aVetStr:={}
    
    cFile := cGetFile("Files (pdf,odg)|*.odg;*.pdf|",;
                      "Select file (pdf/odg)", 4 )
    
    IF EMPTY(cFILE) ; RETURN .F. ; ENDIF
    cFile := "file:///"+StrTran(cFile,"\","/")
    
    oService := TOleAuto():New("com.sun.star.ServiceManager")
    oDesktop := oService:createInstance("com.sun.star.frame.Desktop")
    AAdd(aProp,MakePropertyValue(oService,"Hidden",.T.)) //oculta
    oDoc := oDesktop:loadComponentFromURL(cFile, "_blank", 0, aProp)
    
    oDrawPage := oDoc:getDrawPages():getByIndex(0)
    
    MsgInfo(oDrawPage:getCount())
    //You may add oMeter
    FOR i:=0 TO oDrawPage:getCount()-1
        oShape := oDrawPage:getByIndex(i)
        
        oCursor := oShape:createTextCursor()
        
        cText := oCursor:getText():getString()
        AADD(aVetStr,cText)
    NEXT
    
    oDoc:Close(.T.)
    
    xbrowse(aVetStr)

RETURN NIL

//--------------------------------------------------------//
STATIC FUNCTION MakePropertyValue(oService,cName,nValue)

    LOCAL oStruct := oService:Bridge_GetStruct("com.sun.star.beans.PropertyValue")
    oStruct:Name := cName
    oStruct:Value := nValue
RETURN(oStruct)


Regards
Anser
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Wed Jun 05, 2013 11:53 PM

Muchas gracias anserkk :D

haré unas pruebas y te comento

Gracias :mrgreen:

Saluditos :wink:

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Thu Jun 06, 2013 03:47 AM

no funciona sale este error

Time from start: 0 hours 0 mins 5 secs
Error occurred at: 05-06-13, 22:49:24
Error description: Error com.sun.star.ServiceManager:CREATEINSTANCE:LOADCOMPONENTFROMURL/6 DISP_E_UNKNOWNNAME: GETDRAWPAGES
Args:

Stack Calls

Called from: => TOLEAUTO:GETDRAWPAGES( 0 )
Called from: C:\fwh\PEGASO\PRG\test.prg => PDFTXT( 5891 )
Called from: C:\fwh\PEGASO\PRG\test.prg => (b)MAIN( 630 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 465 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 656 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1714 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1408 )
Called from: C:\FWH\SOURCE\CLASSES\window.prg => _FWH( 3177 )
Called from: => DIALOGBOX( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
Called from: C:\fwh\PEGASO\PRG\test.prg => MAIN( 667 )

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Sat Jun 08, 2013 02:57 AM

a un no logro nada :cry:

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Sat Jun 08, 2013 04:45 AM
It is working fine here on a PDF that contains text. I tested with LibreOffice ver 4.0.0
If u can send me the PDF file, I shall test it here

Regards
Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Sat Jun 08, 2013 06:27 AM

Aida,

Estoy probando un código que podriamos usar sin necesidad de LibreOffice, ni nada más :-)

viewtopic.php?f=6t=26511

&

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Fri Mar 11, 2016 04:34 PM

Antonio buenas tardes

Ya es posible esto desde fw?

Saludos

Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM
Re: Se podrá leer el texto de un PDF y guardar algunos datos ?
Posted: Fri Mar 11, 2016 06:55 PM

Aide , pudiste?
contáctame y lo resolvemos ,
saludos.

SysCtrlSoftware ARROBA Gmail.com

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "

Continue the discussion