Rendering multiple .rdlc reports into a single PDF using PDFSharp

社会主义新天地 提交于 2019-12-10 16:49:57

问题


I am running multiple reports and combining them into a single PDF file. For each report, I pass the datasource, parameters, and report path to the following. The result is a PDF file with the correct number of pages, but all pages are blank. What am I missing?

LocalReport report = null;
PdfDocument pdfDoc = new PdfDocument();

private void ProcessReport(
    ReportDataSource reportDS, 
    ReportParameter[] reportParms, 
    string reportPath)
{
    string format = "PDF";
    string deviceInfo = null;
    string encoding = String.Empty;
    string mimeType = String.Empty;
    string extension = String.Empty;
    Warning[] warnings = null;
    string[] streamIDs = null;

    report = new LocalReport();
    report.EnableExternalImages = true;
    report.ReportPath = reportPath;

    if (reportParms != null)
        report.SetParameters(reportParms);

    if (reportDS != null)
        report.DataSources.Add(reportDS);

    Byte[] pdfArray = report.Render(
        format, 
        deviceInfo, 
        out mimeType, 
        out encoding,
        out extension, 
        out streamIDs, 
        out warnings);

    //Stream s = new MemoryStream(pdfArray);
    MemoryStream ms = new MemoryStream(pdfArray);

    PdfDocument tempPDFDoc = PdfReader.Open(ms, PdfDocumentOpenMode.Import);

    for (int i = 0; i < tempPDFDoc.PageCount; i++)
    {
        PdfPage page = tempPDFDoc.Pages[i];
        pdfDoc.AddPage(page);
    }
}

回答1:


Please try generating the reports with a different setting as described in this thread: http://forum.pdfsharp.net/viewtopic.php?p=1613#p1613

If you provide us with some files that do not work, we can try to fix this in PDFsharp.




回答2:


You need to change your string deviceInfo = null; to deviceInfo="<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>";



来源:https://stackoverflow.com/questions/9788345/rendering-multiple-rdlc-reports-into-a-single-pdf-using-pdfsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!