How to send report in PDF through FTP

2017-02-27

FastReport .Net allows you to export reports in various formats, send them via Email, as well as via FTP. In this article, I want to focus on the transfer to the server via FTP reports. It should be noted, it is not very convenient to run each report and manually perform sending via FTP. What if a large number of reports should be sent to the server?

What are the solutions to this problem:

  1. Send all report files directly using the file manager with FTP-connections. Butbefore all reports should be exported to the desired format;
  2. Arrange export and send  report using FastReport, but do it in the application code.

Obviously, the second way will save time when you export the report in the desired format. In addition, you can completely automate this process. For example, to lay out all of the reports to a server on a schedule or one click a button.

I will show an example in which you will see the simplicity of an operation such as sending report via FTP from the application code.

Create a Windows Forms application. Place a button on the form.

Add the libraries into "using":

1
2
3
using FastReport;
using FastReport.Export;
using FastReport.Utils;

 Add the code for the button click handler:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 private void button1_Click(object sender, EventArgs e)
 {
 Report report1 = new Report(); //Create new report
 FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport(); //Create pdf export object
 report1.Load(Environment.CurrentDirectory+"\\text.frx"); //Load report
 report1.Prepare(); //Prepare report
 
 FastReport.Cloud.StorageClient.Ftp.FtpStorageClient ftp = new FastReport.Cloud.StorageClient.Ftp.FtpStorageClient(); //Create ftp client
 //ftp connection settings
 ftp.Server = "78.47.131.251/Reports";
 ftp.Username = "user";
 ftp.Password = "password";
 ftp.SaveReport(report1, pdf); //Send report
 }

First we create an instance of the report object. Then create the export object to PDF. Then we load the report and perform its construction (Prepare). Create a client to work with FTP. You must specify all three properties: the server, user and password. Do not forget that you need to specify the path to the desired folder, otherwise the reports will be placed directly in the root. Finally, we send a report to the server. As the parameters pass the report itself and export to PDF. FastReport will make a report export and send via FTP prepared file in pdf.

Start the app, press the button and check the existence of the file on the server:

Using this simple procedure, you can send multiple reports in any of the available formats,  HTML for instance. So you can design the reports on a local computer and share them on your website.

 

 

.NET Export FastReport PDF .NET Export FastReport PDF
February 20, 2025

Using Dot Matrix Printers for Printing Receipts

This article will explore how to integrate a dot matrix printer into the process of creating and outputting reports using FastReport .NET.
February 17, 2025

Adding New Users to FastReport Cloud

In the Business edition of the FastReport Cloud service, you can add users to a single workspace for simultaneous collaboration.
February 10, 2025

How to Try FastReport .NET WEB Before Purchase

By testing the WEB pack before purchasing, you can make an informed choice about whether FastReport is suitable for you.NET for your tasks.
Fast Reports
  • 800-985-8986 (English, US)
  • +31 97 01025-8466 (English, EU)
  • +49 30 56837-3928 (German, DE)
  • +55 19 98147-8148 (Portuguese, BR)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2025 Fast Reports Inc.