Select text from .pdf file and show it on the Richtext box. ? Its Challanging....
Hi all,
i am having 3 controls.
Button
AxAcroPDF1
Richtextbox
I select text from pdf file present in AxAcroPDF1 from mouse click, what ever i select immidiately it show be shown on the text on the Richtextbox
Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim dlg As OpenFileDialog = New OpenFileDialog()
' set file filter of dialog
dlg.Filter = "pdf files (*.pdf) |*.pdf;"
dlg.ShowDialog()
If dlg.FileName <> "" Then
AxAcroPDF1.src = dlg.FileName
End If
End Sub
Will be waiting for the reply.
Kind Regards
Seema
Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...
Mean while i just got 1 site in which i found the below code.... But i dnt know how to make it work... so many things r strange i am not getting them how to do... Ur help will be appriciated...
Code:
CAcroAVDoc avDoc;
CAcroPDDoc pdDoc;
CAcroRect acroRect = new AcroRectClass();
CAcroPDTextSelect pdTextSelect;
int startpage;
bool bSelectSet = false;
bool bShowSelect = false;
string szPdfConst = openDialog.FileName;
acroRect.bottom = 225;
acroRect.Left = 140;
acroRect.Top = 230;
acroRect.right = 145;
//Create a new Acrobat App Object
mApp = new AcroAppClass();
mApp.Show();
avDoc = new AcroAVDocClass();
//Lets open the PDF now
if (avDoc.Open(szPdfConst, ""))
{
fileStatus.Text = "Adobe Acrobat document loaded succesfully.";
pdDoc = (CAcroPDDoc)avDoc.GetPDDoc();
startpage = 0;
pdTextSelect = (CAcroPDTextSelect)pdDoc.CreateTextSelect(startpage, acroRect);
bSelectSet = avDoc.SetTextSelection(pdTextSelect);
//If the set was successful
if (bSelectSet)
{
bShowSelect = avDoc.ShowTextSelect();
}
}
else
{
fileStatus.Text = "Adobe Acrobat document could not be loaded.";
}
}
The link is http://forums.adobe.com/thread/567307
Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...
Quote:
Originally Posted by
SeemsP
Mean while i just got 1 site in which i found the below code.... But i dnt know how to make it work... so many things r strange i am not getting them how to do... Ur help will be appriciated...
Code:
CAcroAVDoc avDoc;
CAcroPDDoc pdDoc;
CAcroRect acroRect = new AcroRectClass();
CAcroPDTextSelect pdTextSelect;
int startpage;
bool bSelectSet = false;
bool bShowSelect = false;
string szPdfConst = openDialog.FileName;
acroRect.bottom = 225;
acroRect.Left = 140;
acroRect.Top = 230;
acroRect.right = 145;
//Create a new Acrobat App Object
mApp = new AcroAppClass();
mApp.Show();
avDoc = new AcroAVDocClass();
//Lets open the PDF now
if (avDoc.Open(szPdfConst, ""))
{
fileStatus.Text = "Adobe Acrobat document loaded succesfully.";
pdDoc = (CAcroPDDoc)avDoc.GetPDDoc();
startpage = 0;
pdTextSelect = (CAcroPDTextSelect)pdDoc.CreateTextSelect(startpage, acroRect);
bSelectSet = avDoc.SetTextSelection(pdTextSelect);
//If the set was successful
if (bSelectSet)
{
bShowSelect = avDoc.ShowTextSelect();
}
}
else
{
fileStatus.Text = "Adobe Acrobat document could not be loaded.";
}
}
The link is
http://forums.adobe.com/thread/567307
Well i reached to the point here that i think using AVDoc , PDDoc - we cn copy the text... i m not sure... Plz help me it v urget
Code:
Dim PDDoc As Object
Dim AVDoc As Object
Dim AcroExchApp As Object
AcroExchApp = CreateObject("AcroExch.App")
AVDoc = AcroExchApp.GetActiveDoc
PDDoc = AVDocTarget.GetPDDoc
If PDDoc.Save(PDSaveFull, "c:\test.pdf") = False Then
MsgBox("Unable to save image")
Else : MsgBox("The file is saved")
End If
Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...
Quote:
Originally Posted by
SeemsP
Hi all,
i am having 3 controls.
Button
AxAcroPDF1
Richtextbox
I
select text from pdf file present in
AxAcroPDF1 from mouse click, what ever i select immidiately it show be shown on the text on the Richtextbox
Have you ever thought using pdf text coordinate system to select text from pdf?
Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...
I searched internet and found the following thread that might help you to get Text from axAcroPDF control:
https://social.msdn.microsoft.com/Fo...=csharpgeneral
I am currently using leadtools SDK to extract text from pdf documents using PDFDocument class. I found the following page that might help:
https://www.leadtools.com/help/leadt...arsepages.html