|
|||
Text searching
im newbie here.. nak tanya pada pakar2 yg ade kat sini..
sekarang ni saya guna ASP.. saya nak cari perkataan dalam pdf file, guna ASP.. how to do? saya tengah download PDF SDK.. tp x tau la betul ke step saya ni.. contoh: bila taip "hello", system akan baca text dlm pdf dan show pdf file mana yang ade "hello" urgent ni..plz help..tq (sorry kalau issue ni dah dipost sblm ni) |
|
|||
|
|||
Quote:
senario is, im trying to develop some kind of knowledge base..ala-ala la..hehe. so when user key in 'hello', wat happen is system will open all find that stored in one specific path ..like C:\\my doc..then the system will read n search that 'hello'.. so en.Genzy, wat do u mean if the acrobat reader is installed? and i dont actually open the pdf file in web browser?..can xplain a bit? tq.. |
|
||||
For References:
Unable To Access Objects In Visual Basic Code:
Dim avdoc as Object, app as object, pddoc as Object
set app = CreateObject("AcroExch.App")
set avdoc = CreateObject("AcroExch.AVDoc")
avdoc.open "c:\test.pdf", "Temp Title"
if (avdoc.IsValid = True) Then
set pddoc = avdoc.GetPDDoc()
End If
Code:
I use this class to merge PDF files using Acrobat be sure to set a reference to "Adobe Acrobat x.x Type Library"
'---------------- START CODE --------------------------------------------------------
Option Compare Database
Option Explicit
Private colDOCS As Collection 'PDF Files to merge
Private strDestination As String 'Destination PDF Doc.
Private bolDeleteCoverPage As Boolean
Sub AddFile(strNewData As String)
colDOCS.ADD strNewData
End Sub
Sub ClearFileList()
'PURPOSE: remove Files in Collection. Set Collection to nothing and reinitalize
If Not colDOCS Is Nothing Then Set colDOCS = Nothing
Set colDOCS = New Collection
End Sub
Property Let Destination(strDest As String)
strDestination = strDest
End Property
Function Merge() As Long
On Error GoTo Proc_Error
Dim objAcroApp As Acrobat.CAcroApp
Dim objAcroDoc As Acrobat.CAcroPDDoc
Dim objAcroDocSrc As Acrobat.CAcroPDDoc
Dim lngRetVal As Long
Dim I As Long
Dim lngPage As Long
Set objAcroApp = CreateObject("AcroExch.App")
Set objAcroDoc = CreateObject("AcroExch.PDDoc")
Set objAcroDocSrc = CreateObject("AcroExch.PDDoc")
lngRetVal = objAcroDoc.Open(colDOCS.Item(1))
lngPage = objAcroDoc.GetNumPages
For I = 2 To colDOCS.Count
lngRetVal = objAcroDocSrc.Open(colDOCS.Item(I))
If lngRetVal = False Then
MsgBox ("Error Opening " + colDOCS.Item(I))
Merge = False
GoTo Proc_Exit
End If
Merge = objAcroDoc.InsertPages((lngPage - 1), objAcroDocSrc, 0, objAcroDocSrc.GetNumPages, False)
lngPage = lngPage + objAcroDocSrc.GetNumPages
objAcroDocSrc.Close
Next I
objAcroDoc.CreateThumbs 0, lngPage - 1
Merge = objAcroDoc.Save(PDSaveFull, strDestination)
objAcroDoc.Close
objAcroApp.Exit
Proc_Exit:
If Not objAcroApp Is Nothing Then Set objAcroApp = Nothing
If Not objAcroDoc Is Nothing Then Set objAcroDoc = Nothing
If Not objAcroDocSrc Is Nothing Then Set objAcroDocSrc = Nothing
Exit Function
Proc_Error:
MsgBox Err.Description
Merge = Err.Number
Resume Proc_Exit
End Function
Private Sub Class_Initialize()
Set colDOCS = New Collection
End Sub
Private Sub Class_Terminate()
On Error Resume Next
If Not colDOCS Is Nothing Then Set colDOCS = Nothing
End Sub
Quote:
Code:
' Declaration
Structure Rect
Dim Left As Integer
Dim Top As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure
Declare Function GetWindow Lib "user32" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, _
ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Declare Function GetClientRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As Rect) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Private Declare Function GetWindowRect Lib "user32" (ByVal Hwnd As Integer, ByRef lpRect As Form1.Rect) As Integer
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Integer) As Integer
Private Declare Function MoveWindow Lib "user32" (ByVal Hwnd As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer
Private AcroHandle As Integer
Private AcroXApp As Acrobat.CAcroApp
Private AcroXAVDoc As Acrobat.CAcroAVDoc
Private AcroXPDDoc As Acrobat.CAcroPDDoc
Private FormApp As AFORMAUTLib.AFormApp
Private AcroForm As AFORMAUTLib.Fields
Private Field As AFORMAUTLib.Field
' Methods
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim FileName As String
AcroXApp = CType(CreateObject("AcroExch.App"), Acrobat.CAcroApp)
'Removing toolbar buttons from the user interface
With AcroXApp
.ToolButtonRemove("Save")
.ToolButtonRemove("Open")
.ToolButtonRemove("AcroForm:WidgetTool")
End With
AcroXAVDoc = CType(CreateObject("AcroExch.AVDoc"), Acrobat.CAcroAVDoc)
FileName = "C:\'Your path and pdf file name'"
AcroXAVDoc.Open(FileName, "Acrobat")
AcroHandle = FindWindow(vbNullString, "Adobe Acrobat Professional - [Acrobat]")
SetParent(AcroHandle, Panel1.Handle.ToInt32) 'put Acrobat in winform panel. The panel is docked to all four sides of the form. In VB6 you need to resize the panel with the form
'Show in winform (not in a panel) alternative to above:
'AcroXAVDoc.OpenInWindowEx(FileName, Me.Panel1.Handle.ToInt32, 1, 1, 0, 0, 2, 0, 0, 0)
'I've found this is not as flexible
'The following is to fill Acrobat fields with data
AcroXPDDoc = CType(AcroXAVDoc.GetPDDoc, Acrobat.CAcroPDDoc)
FormApp = CType(CreateObject("AFormAut.App"), AFORMAUTLib.AFormApp)
AcroForm = CType(FormApp.Fields, AFORMAUTLib.Fields)
For Each Field In AcroForm
Field.Value = "This is a test of how well this works, and if I have this right, I can be happy."
Next
AcroXPDDoc.ClearFlags(&H1) 'Keep Acrobat from querying a file save when component closes
SetAcroSize(AcroHandle, Panel1)
AcroXApp.Show()
End Sub
Private Sub SetAcroSize(ByRef lngHwnd As Integer, ByRef AcroPanel As System.Windows.Forms.Panel)
'Hide the title bar and menus from the user
'and resize Acrobat with the resizing of the form
Dim lngX As Integer 'acro left position
Dim lngY As Integer 'acro top position
Dim lngW As Integer 'acro width
Dim lngH As Integer 'acro height
Dim AppRect As Form1.Rect
GetWindowRect(AcroPanel.Handle.ToInt32, AppRect)
lngX = -GetSystemMetrics(32)
lngY = -GetSystemMetrics(33) - 37
lngW = AppRect.Right - AppRect.Left - lngX * 2
lngH = AppRect.Bottom - AppRect.Top - lngY * 2 - 37
MoveWindow(lngHwnd, lngX, lngY, lngW, lngH, 1)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
SetAcroSize(AcroHandle, Panel1)
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
'If acrobat is not properly closed, you end up with the acrobat.exe process continuing to run,
'but Acrobat will not be visible. This will baffle you to no end until you "end process"
'with Windows task manager while testing your app.
AcroXApp.Hide()
SetParent(AcroHandle, 0)
AcroXAVDoc.Close(0)
AcroXApp.CloseAllDocs()
AcroXApp.Exit()
End Sub
Code:
Private Sub Command1_Click()
'Declare acrobat objects and other variables
Dim gApp As Object 'Acrobat.CAcroApp
Dim AcroExchAVDoc As Object 'CAcroAVDoc
Dim AVPage As Object 'CAcroAVPageView
Dim bOK, bFound As Boolean
Dim i As Long, lngPage As Long
Dim lngAnswer As Long
'Create the Acrobat objects.
Set gApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
gApp.Show
bOK = AcroExchAVDoc.Open("C:\My Documents\MyPDFs\STRUTS.pdf", "")
If (bOK) Then
bFound = AcroExchAVDoc.FindText("Reinstall", True, True, True)
If (bFound) Then
Set AVPage = AcroExchAVDoc.GetAVPageView
lngPage = AVPage.GetPageNum
MsgBox ("Text found on this Page: " & (lngPage + 1))
Set AVPage = Nothing
End If
Else
lngAnswer = MsgBox("Text Not Found!!!", vbCritical, "Text Not Found")
End If
Stop
AcroExchAVDoc.ClearSelection
AcroExchAVDoc.Close 1
Set AcroExchAVDoc = Nothing
'Quit Acrobat.
gApp.Exit
End Sub
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Searching for stall to rent? | Aunty Nat | Mamak Stall | 1 | 20-11-2005 09:45 PM |
| searching for asp.net project | lighching | Other Webmaster-related Services and Promotion | 2 | 05-08-2005 01:31 PM |
| Searching for shopping cart | K-C | E-Commerce | 15 | 19-07-2005 09:55 PM |
| Searching for JOBS? | JobListed | Websites Review and Suggestion | 0 | 17-05-2005 04:58 PM |
| searching..... | nurulmajdi | Website Programming | 1 | 01-03-2004 06:15 PM |
All times are GMT +8. The time now is 07:04 PM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.












Linear Mode

