Display pdf file on web with search text functionality

Go To StackoverFlow.com

0

Can anyone tell, how to display pdf file on web with search text functionality.

2012-04-04 06:27
by justshahzad
you want to search inside the pdf files - Ali Issa 2012-04-04 06:42
yes display pdf file in aspx page having search text functionality - justshahzad 2012-04-04 06:58
ok then, look at my answer below, it should be very easy to implemen - Ali Issa 2012-04-04 07:08


2

If you mean searching inside the pdf files, you can do this:

  • download this dll Interop.Cisso.DLL and then add it as a reference
  • Create your catalog (you should define a catalog in the indexing service to search inside it) it is done this way: http://support.microsoft.com/kb/308202
  • finally here is your code for doing the search:

       DataSet ds = new DataSet("IndexServerResults");
        CissoQueryClass q = new CissoQueryClass();
        CissoUtilClass util = new CissoUtilClass();
    
        OleDbDataAdapter da = new OleDbDataAdapter();
    
    string query = "";
    if (lstSearchIntegration.SelectedValue == "-1") {
        query = "@all Contains " + txtKeywordOne.Text + " and not #filename *.log";
    } else {
        string operation = "";
        if (lstSearchIntegration.SelectedValue.ToLower == "and") {
            operation = "and";
        } else {
            operation = "or";
        }
        query = "@all Contains " + txtKeywordOne.Text + " " + operation + " " + txtKeywordTwo.Text;
    
     }
    
    switch (lstDocType.SelectedValue) {
        case "doc":
            query += " and #filename *.doc";
            break;
        case "pdf":
            query += " and #filename *.pdf";
            break;
        case "ppt":
            query += " and #filename *.ppt";
            break;
        case "pps":
            query += " and #filename *.pps";
            break;
    }
    
    q.Query = query;
    q.Catalog = "YourCatalogName";
    q.SortBy = "rank[d]";
    q.Columns = "DocAppName,rank, path, size, FileName,VPath, Create";
    
    q.MaxRecords = 1000;
        util.AddScopeToQuery(q, "YourFolder", "deep");
    object obj = q.CreateRecordset("nonsequential");
    da.Fill(ds, obj, "IndexServerResults");
    DataTable mydt = new DataTable();
    mydt = ds.Tables[0];
    

Please note that:

  1. I am using and/or operations for smarter search
  2. I am searching inside doc,pdf,ppt and pps
  3. I am excluding log files from search
2012-04-04 07:06
by Ali Issa


0

I can suggest Aspose.PDF but it costs money

2012-04-04 07:00
by Denis Palnitsky
Ads