Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adobe Acrobat Automation
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01019178
Message ID:
01020040
Vues:
43
Thank you very much Sergey.
I´ll study your code and certainly it´ll be very useful.
Thanks again.

Regards,

>>Hi, I need to find some keywords inside a PDF document, store all ocurrences in a Table with the page and position of the keyword (inside the document)and present this page to the users with the keyword highlighted. Anyone can help me?
>
>Below's a sample code that shows how to find all pages with specified text. For details see Acrobat Interapplication Communication Reference which you can download from http://partners.adobe.com/public/developer/acrobat/sdk/index_doc.html
>
CLEAR
>loAcroApp = CREATEOBJECT("AcroExch.App")
>loAcroApp.Minimize(.T.)
>loAcroApp.Show()
>loAVDoc = CREATEOBJECT("AcroExch.AVDoc")
>lcPdfFile = "Q:\DEV\HELP\OfficeAutomationVFP.pdf"
>loAVDoc.Open(lcPdfFile, "PDF")
>loAvPage = loAVDoc.GetAVPageView()
>loPDDoc = loAVDoc.GetPDDoc()
>* # of pages in the PDF
>lnNumPages = loPDDoc.GetNumPages()
>
>loAVDoc.ClearSelection()
>
>CREATE CURSOR crsTextFound ( PageNum I, Offset I)
>
>llCaseSensitive  = .T.
>llWholeWordsOnly = .T.
>* Start search from the beginning (Page 0)
>llReset = .T.
>lcSearchFor = "Advanced"
>
>llTextFound = loAVDoc.FindText(lcSearchFor, llCaseSensitive, llWholeWordsOnly, llReset)
>* Start search on the current page
>llReset = .F.
>lnCount = 0
>lnPageNum = 0
>
>DO WHILE llTextFound
>	lnOffset = 0
>	lnPageNum = loAvPage.GetPageNum()
>	INSERT INTO crsTextFound  VALUES (lnPageNum, lnOffset)
>	lnCount = lnCount + 1
>	IF lnPageNum+1 >= lnNumPages
>		EXIT
>	ENDIF
>	loAVPage.Goto(lnPageNum+1)
>	llTextFound = loAVDoc.FindText(lcSearchFor, llCaseSensitive, llWholeWordsOnly, llReset)
>	WAIT WINDOW NOWAIT "Page " + TRANSFORM(lnPageNum+1) + " of " + TRANSFORM(lnNumPages)
>ENDDO
>
>loAcroApp.Restore(.T.)
>
>IF RECCOUNT() > 0
>	* Move to the first page where text has been found
>	GO TOP
>	loAVPage.Goto(crsTextFound.PageNum)
>	llTextFound = loAVDoc.FindText(lcSearchFor, llCaseSensitive, llWholeWordsOnly, llReset)
>ENDIF	
>
>loAvPage = Null
>
>* Close acrobat, if necessary
>*loPDDoc.Close()
>*loPDDoc = Null
>*loAVDoc.Close(.T.)
>*loAVDoc = Null
>
>* Exit acrobat
>*loAcroApp.Exit()
>
>WAIT CLEAR
>RETURN
>
José Augusto Cavalcanti
Global Connection
jose.cavalcanti@globalconnection.com.br
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform