RDLC Report in .NET 4.7.2 – PDF Generation Not Displaying Content

I’m working on a .NET Framework 4.7.2 project using the Class Library template. I’m trying to generate a PDF report using RDLC, but the PDF file is generated without displaying any content, not even static data.

RDLC Report Setup:

I created an RDLC report file (SummonsReport.rdlc) with static text and images to ensure that some content should be displayed.
Report Generation Code:
[HttpGet]
[Route(“GenerateSummonsReports”)]
public HttpResponseMessage GenerateSummonsReports(long session_id)
{
try
{
// Fetch the data
IList summonsData = new Summons().GetSummonsForPrint(session_id);
Debug.WriteLine($”Fetched {summonsData.Count} summons records.”);

    // Create a DataSet and DataTable
    DataSet dataSet = new DataSet("SummonTemplateDataset");
    DataTable dataTable = new DataTable("DataTable_Summon");

    // Add columns to DataTable
    dataTable.Columns.Add("citizen_id", typeof(long));
    dataTable.Columns.Add("entity_id", typeof(long));
    dataTable.Columns.Add("name", typeof(string));
    dataTable.Columns.Add("contact_number", typeof(string));
    dataTable.Columns.Add("address", typeof(string));
    dataTable.Columns.Add("date_of_birth", typeof(DateTime));
    dataTable.Columns.Add("profession", typeof(string));
    dataTable.Columns.Add("session_id", typeof(long));
    dataTable.Columns.Add("status_id", typeof(long));
    dataTable.Columns.Add("summon_file", typeof(string));

    // Populate DataTable with data
    foreach (var summon in summonsData)
    {
        dataTable.Rows.Add(
            summon.citizen_id,
            summon.entity_id,
            summon.name,
            summon.contact_number,
            summon.address,
            summon.date_of_birth,
            summon.profession,
            summon.session_id,
            summon.status_id,
            summon.summon_file
        );
    }

    // Add DataTable to DataSet
    dataSet.Tables.Add(dataTable);

    // Path to your RDLC report file
    string reportPath = HostingEnvironment.MapPath("~/Reports/SummonsReport.rdlc");

    // Check if the file exists at the specified path
    if (!File.Exists(reportPath))
    {
        throw new FileNotFoundException($"Report file not found at path: {reportPath}");
    }

    // Initialize LocalReport
    LocalReport localReport = new LocalReport
    {
        ReportPath = reportPath
    };

    // Set the data source for the current report
    ReportDataSource reportDataSource = new ReportDataSource("SummonTemplateDataset", dataTable);
    localReport.DataSources.Clear();
    localReport.DataSources.Add(reportDataSource);

    // Render the report to a byte array
    string reportType = "PDF";
    string mimeType;
    string encoding;
    string fileNameExtension;
    string[] streams;
    Warning[] warnings;

    byte[] renderedBytes = localReport.Render(
        reportType,
        null,
        out mimeType,
        out encoding,
        out fileNameExtension,
        out streams,
        out warnings);

    // Log warnings if any
    if (warnings != null && warnings.Length > 0)
    {
        foreach (var warning in warnings)
        {
            Debug.WriteLine($"Warning: {warning.Message}");
        }
    }

    // Return the PDF report
    HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new ByteArrayContent(renderedBytes)
    };
    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
    {
        FileName = $"SummonsReport_{session_id}.pdf"
    };

    return response;
}
catch (Exception ex)
{
    Debug.WriteLine($"Exception: {ex.Message}");
    return new HttpResponseMessage(HttpStatusCode.InternalServerError)
    {
        Content = new StringContent($"Error generating report: {ex.Message}")
    };
}

}

Result:
The PDF file is created successfully, but it does not display any content. The PDF is blank.

What I’ve Tried:
I verified that the RDLC file is correctly set up with static text and images.
I confirmed that the ReportPath is correct.
I tried adding different data sources, but the result remains the same (blank PDF).
I’ve checked for any runtime errors, but there are none.

Environment Details:
.NET Framework: 4.7.2
Template: Class Library
Tools: Visual Studio 2022

New contributor

Abhay Kamble is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật