Преобразование нескольких отчетов .rdlc в один PDF-файл с помощью PDFSharp

Я запускаю несколько отчетов и объединяю их в один файл PDF. Для каждого отчета я передаю источник данных, параметры и путь к отчету следующему. В результате получается файл PDF с правильным количеством страниц, но все страницы пустые. Что мне не хватает?

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);
    }
}

person RememberME    schedule 20.03.2012    source источник


Ответы (2)


Попробуйте создать отчеты с другими настройками, как описано в этой теме: http://forum.pdfsharp.net/viewtopic.php?p=1613#p1613

Если вы предоставите нам некоторые файлы, которые не работают, мы можем попытаться исправить это в PDFsharp.

person I liked the old Stack Overflow    schedule 21.03.2012
comment
Не знаете, куда поместить "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>" (как указано в приведенной ссылке) этот код, может ли кто-нибудь поделиться кодом, в котором происходят эти изменения? Спасибо - person Рахул Маквана; 03.05.2017

Вам нужно изменить строку deviceInfo = null; до deviceInfo="<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>";

person Hamza Shafiq    schedule 07.02.2018