Select text from .pdf file and show it on the Richtext box. ? Its Challanging....
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Select text from .pdf file and show it on the Richtext box. ? Its Challanging....

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    23

    Thumbs up 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

  2. #2
    Join Date
    Jan 2013
    Posts
    23

    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

  3. #3
    Join Date
    Jan 2013
    Posts
    23

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    Quote Originally Posted by SeemsP View Post
    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

  4. #4
    Join Date
    Mar 2014
    Posts
    5

    Re: Select text from .pdf file and show it on the Richtext box. ? Its Challanging...

    Quote Originally Posted by SeemsP View Post
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center