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

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    28 posts
    Member since:
    Jul 2018

    Posted 30 Nov 2018 Link to this post

    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.

  2. Silviya
    Admin
    Silviya avatar
    344 posts

    Posted 05 Dec 2018 Link to this post

    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
  3. Daniel
    Daniel avatar
    28 posts
    Member since:
    Jul 2018

    Posted 05 Dec 2018 in reply to Silviya Link to this post

    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.
  4. Silviya
    Admin
    Silviya avatar
    344 posts

    Posted 05 Dec 2018 Link to this post

    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
Back to Top