Fastreport Mono under Debian, how to create pdf from frx-file

My first use is Fastreport-Desktop under Windows. I create an frx-file with the designer-programm. After that I call fastreport.exe (sorry, don't know syntax exactly, because I am not in my office) with a parameter-file and frx-file. The result is a pdf-file.

I wish I could do this in my debian-linux environment. So I installed a brand new debian-machine with graphical X-environment. Download fastreport-mono and install it:

# install mono:
apt-get install gnupg dirmngr apt-transport-https ca-certificates -y
apt remove --purge --auto-remove mono-runtime
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

sudo sh -c 'echo "deb https://download.mono-project.com/repo/debian stable-buster main" > /etc/apt/sources.list.d/mono-official-stable.list'
apt-get update
apt-get install mono-complete

# install fastreport
lynx https://www.fast-report.com/en/download/fast-report-mono/
dpkg -i fastreport-mono-demo_all.deb

I find a lot of frx-files, for example:

/usr/share/fastreport-mono-demo/Demo/Demos/Reports/Text.frx

How can I create a very simple pdf-file from this frx file from the command line?

Thanks for your help,

Richard

Comments

  • Hello!

    The FastReport.Mono package does not include a separate, ready-to-use command-line executable, but a compact C# console utility can be written in just a few lines to convert reports to PDF in batches on Linux (Debian).

    1. Create a file called fr2pdf.cs:

    namespace FrCli
    {
      class Program
      {
        static int Main(string[] args)
        {
          if (args.Length < 2)
          {
            Console.WriteLine(‘Usage: mono fr2pdf.exe <input.frx> <output.pdf> [data.xml]’);
            return 1;
          }
          string frxPath = args[0];
          string pdfPath = args[1];
          if (!File.Exists(frxPath))
          {
            Console.Error.WriteLine(‘Error: template file not found: ’ + frxPath);
            return 2;
          }
          // Suppress GUI dialogues and progress pop-ups
          Config.WebMode = true;
          using (var report = new Report())
          {
            report.Load(frxPath);
    
            // If there is an external source of XML data
            if (args.Length >= 3 && File.Exists(args[2]))
            {
              var ds = new System.Data.DataSet();
              ds.ReadXml(args[2]);
              report.RegisterData(ds);
            }
            report.Prepare();
    
            using (var pdf = new PDFExport())
            {
              pdf.ShowProgress = false;
              pdf.EmbeddingFonts = true;
              report.Export(pdf, pdfPath);
            }
          }
          Console.WriteLine(‘PDF successfully generated: ’ + pdfPath);
          return 0;
        }
      }
    }
    

    2. Compile the utility using the Mono C# Compiler (mcs):

    mcs -r:/usr/lib/mono/fastreport/FastReport.Mono.dll -r:System.Drawing.dll,System.Data.dll,System.Xml.dll -out:fr2pdf.exe fr2pdf.cs

    3. Run the PDF generation:

    mono fr2pdf.exe /usr/share/fastreport-mono-demo/Demo/Demos/Reports/Text.frx output.pdf

This discussion has been closed.