使用搜索文本功能在Web上显示pdf文件

时间:2012-04-04 06:27:36

标签: c# asp.net .net

任何人都可以说,如何在网页上显示带有搜索文字功能的pdf文件。

2 个答案:

答案 0 :(得分:2)

如果您的意思是在pdf文件中搜索,您可以这样做:

  • 下载此dll Interop.Cisso.DLL,然后将其添加为参考
  • 创建目录(您应该在索引服务中定义目录以在其中进行搜索)以这种方式完成:http://support.microsoft.com/kb/308202
  • 最后这是您进行搜索的代码:

       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];
    

请注意:

  1. 我正在使用和/或操作更智能的搜索
  2. 我正在搜索doc,pdf,ppt和pps
  3. 我从搜索中排除日志文件

答案 1 :(得分:0)

我可以建议Aspose.PDF,但要花钱