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

Can I create a report in designer, populate it using C#, save the final version as a PDF and send it to the printer?

3 Answers 661 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 30 Nov 2018, 09:01 PM

Sorry for the long title.  I'm working on a program that will create a transaction ticket.  These tickets need to be saved to a server for auditing purposes in PDF format.  I also need to simultaneously send it to the printer in silent mode with a user defined amount of copies (I will pass this using C#).  In the past I used PdfSharp to create the PDF programmatically, I could then use Ghostscript.NET to send the PDF to the default printer silently with the amount of copies I wanted.  It works well but is tedious. It also requires more dependencies than I'm comfortable with but it's free and it worked at the time.

I'm hoping I can create the ticket template using the Telerik report designer. Somehow load this trdp file into memory using C# and populate some fields in that report with actual values. (I still have to look up how to add fields without a data source).  I don't want to use a data source if I can help it because the data comes from a few locations that I already have access to in memory so it would be much easier to just inject them at runtime.

Is this possible with Telerik? I apologize if this is a basic question but I couldn't find this in the documentation.

3 Answers, 1 is accepted

Sort by
0
Silviya
Telerik team
answered on 05 Dec 2018, 03:00 PM
Hello Daniel,

The standard scenario to print a report directly is to create a report with the available report designers, then use any of the available data source components to supply data in the report, in your case, for example ObjectDataSource. Then you can wrap the report in a report source object and set it to the ReportProcessor.PrintReport Method (ReportSource, PrinterSettings)

Note that you can modify the report definition (i.e. add Report.DataSource) also in the code by instantiating the report, and passing it to the ReportProcessor wrapped in an InstanceReportSource.

Details how to export and print programmatically are available in Exporting Report Programmatically and Print Report straight to printer.

Regards,
Silviya
Progress 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
0
Daniel
Top achievements
Rank 1
answered on 05 Dec 2018, 03:02 PM
Ok, this appears to be exactly what I'm looking for, thanks so much.  I haven't read the articles yet since this project is on hold but this is going to save me and future developers a lot of headaches.  I can't wait to try it out.
0
Silviya
Telerik team
answered on 05 Dec 2018, 03:25 PM
Hi Daniel,

Sure, take your time testing and let us know if you need more assistance.

Regards,
Silviya
Progress 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
Daniel
Top achievements
Rank 1
Answers by
Silviya
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or