PDF file is empty

2 posts, 0 answers
  1. Michael M
    Michael M avatar
    1 posts
    Member since:
    Mar 2010

    Posted 25 Apr 2016 Link to this post


    I have created a simple report using the standalone report designer and saved it as a .trdx file.
    Here is my code to generate a pdf file:

    Reporting.Report report = new Reporting.Report();
    Reporting.XmlReportSource xmlReportSource = new Reporting.XmlReportSource();

    // simple text box (Test2) in a report header

    xmlReportSource.Xml = @"<?xml version='1.0' encoding='utf-8'?>
    <Report Width='6.5in' Name='Report2' xmlns='http://schemas.telerik.com/reporting/2012/3.7'>
        <PageHeaderSection Height='0.200039307276408in' Name='pageHeaderSection1' />
        <DetailSection Height='0.299960772196452in' Name='detailSection1' />
        <PageFooterSection Height='1in' Name='pageFooterSection1' />
        <ReportHeaderSection Height='1in' Name='reportHeaderSection1'>
            <TextBox Width='1.20000016689301in' Height='0.19999997317791in' Left='2.64583333333333in' Top='0.395833333333333in' Value='Test2' Name='textBox1' />
            <Padding Left='2pt' Right='2pt' />
            <TypeSelector Type='TextItemBase' />
            <TypeSelector Type='HtmlTextBox' />
        <PageSettings PaperKind='Letter' Landscape='False' ColumnCount='1' ColumnSpacing='0in'>
            <MarginsU Left='1in' Right='1in' Top='1in' Bottom='1in' />
    report.DataSource = xmlReportSource;
    Processing.ReportProcessor reportProcessor = new Processing.ReportProcessor();
    Reporting.InstanceReportSource instanceReportSource = new Reporting.InstanceReportSource();
    instanceReportSource.ReportDocument = report;
    File.WriteAllBytes(fileName, reportProcessor.RenderReport("PDF", instanceReportSource, null).DocumentBytes);

    File created successfully, but it's empty, althogh report designer previews report properly.
    What am I doing wrong?
    I use Telerik.Reporting, Version=
    Thanks in advance

  2. Katia
    Katia avatar
    596 posts

    Posted 27 Apr 2016 Link to this post

    Hello Michael,

    Test passing xmlReportSource to reportProcessor.RenderReport() method instead of instanceReportSource.

    Also, report.DataSource property can only be set to one of the DataSourceComponents but not to ReportSource.
    Report Sources are used by the viewers when specifying the source for report to display in the viewer.

    You can set DataSource property of the report in Standalone Designer. Note, that you can import reports created with Standalone Designer in Visual Studio and vice versa.

    If you still receive a blank report please open a support ticket and attach a sample project reproducing e problematic behavior so we can test it locally.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top