This is a migrated thread and some comments may be shown as answers.

PDF file is empty

1 Answer 259 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael M
Top achievements
Rank 1
Michael M asked on 25 Apr 2016, 08:10 PM

Hello,

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'>
  <Items>
    <PageHeaderSection Height='0.200039307276408in' Name='pageHeaderSection1' />
    <DetailSection Height='0.299960772196452in' Name='detailSection1' />
    <PageFooterSection Height='1in' Name='pageFooterSection1' />
    <ReportHeaderSection Height='1in' Name='reportHeaderSection1'>
      <Items>
        <TextBox Width='1.20000016689301in' Height='0.19999997317791in' Left='2.64583333333333in' Top='0.395833333333333in' Value='Test2' Name='textBox1' />
      </Items>
    </ReportHeaderSection>
  </Items>
  <StyleSheet>
    <StyleRule>
      <Style>
        <Padding Left='2pt' Right='2pt' />
      </Style>
      <Selectors>
        <TypeSelector Type='TextItemBase' />
        <TypeSelector Type='HtmlTextBox' />
      </Selectors>
    </StyleRule>
  </StyleSheet>
  <PageSettings>
    <PageSettings PaperKind='Letter' Landscape='False' ColumnCount='1' ColumnSpacing='0in'>
      <Margins>
        <MarginsU Left='1in' Right='1in' Top='1in' Bottom='1in' />
      </Margins>
    </PageSettings>
  </PageSettings>
</Report>";
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=8.2.14.1222
Thanks in advance
Michael

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 27 Apr 2016, 03:55 PM
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 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.


Regards,
Katia
Telerik
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
Tags
General Discussions
Asked by
Michael M
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or