pdf中的报告文件无法在我的网站中打开

时间:2017-02-16 08:38:01

标签: asp.net sql-server pdf reporting-services crystal-reports

我正在一个网站上使用SSRS生成报告。

我有三份报告。我需要将这三份报告合并起来,形成一份主要报告。

我传递参数以动态地从我的网站生成报告,并根据参数ssrs生成三个报告。并且报告存储在虚拟目录中。我的网站正常工作,直到这个。我的虚拟目录中有3个报告。

我的问题是,当我尝试访问3个报告以生成主报告时,它会显示错误

  

D:\ Work \ Report \ Reporting Site   31012017 \ DAnalytics.Web \报告\ a9ecd7da-900D-4530-B191-a08995d309e6.pdf   找不到文件或资源。 “

但在我的虚拟文件夹中存在这些文件。

我正在使用visual studio 2012,SQL server 2008 r2

我正在使用代码

public string MergeDocs(Dictionary<int, string> _Files)
    {

        string _CombinedPDFPath = string.Empty;
        if (_Files.Count > 0)
        {
            _CombinedPDFPath = Path.Combine(Path.GetDirectoryName(_Files[0]), "DR_" + DateTime.Now.ToString("ddMMHHmmss") + ".pdf");

            //Step 1: Create a Docuement-Object
            Document document = new Document();
            try
            {
                //Step 2: we create a writer that listens to the document
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(_CombinedPDFPath, FileMode.Create));
                //Step 3: Open the document
                document.Open();

                PdfContentByte cb = writer.DirectContent;
                PdfImportedPage page;

                int n = 0;
                int rotation = 0;

                //Loops for each file that has been listed
                for (int iCount = 0; iCount < _Files.Count; iCount++)
                {
                    //The current file path
                    //  string filePath = sourcefolder + filename; 

                    // we create a reader for the document
                    PdfReader reader = new PdfReader(_Files[iCount]);

                    //Gets the number of pages to process
                    n = reader.NumberOfPages;

                    int i = 0;
                    while (i < n)
                    {
                        i++;
                        document.SetPageSize(reader.GetPageSizeWithRotation(1));
                        document.NewPage();

                        //Insert to Destination on the first page
                        if (i == 1)
                        {
                            Chunk fileRef = new Chunk(" ");
                            fileRef.SetLocalDestination(_Files[iCount]);
                            document.Add(fileRef);
                        }

                        page = writer.GetImportedPage(reader, i);

                        rotation = reader.GetPageRotation(i);
                        if (rotation == 90 || rotation == 270)
                        {
                            cb.AddTemplate(page, 0, -1f, 1f, 0, 0,
                          reader.GetPageSizeWithRotation(i).Height);
                        }
                        else
                        {
                            cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
                        }
                    }
                }

            }
            catch (Exception e) { throw e; }
            finally
            {
                document.Close();
                //AddIndex(_CombinedPDFPath);
            }
        }
        return _CombinedPDFPath;
    }

请帮我解决这个问题。

0 个答案:

没有答案
相关问题