Skip to content

2001 Gtk Viewer Linux

Peter Gill edited this page May 3, 2024 · 10 revisions

The RdlGtkViewer project is a gtk# (gtk-sharp) 2 My-FyiReporting viewer and widget. Add a reference to the RdlGtkViewer assembly in your project and then add the RdlGtkViewer widget to one of your forms.

There is an in progress migration to gtk 3 found in Majorsilence.Reporting.RdlGtk3 but it currently only works on Windows.

Gtk Rdl Viewer in Action

Lets say I added a new instance of the RdlGtkViewer class called viewer to my project. I can load a report with parameters with the following line of code.

RdlGtkViewer viewer = new RdlGtkViewer();
viewer.LoadReport(new Uri(@"/home/peter/Projects/My-FyiReporting/Examples/SqliteExamples/SimpleTest3WithParameters.rdl"), 
    "TestParam1=Hello and Goodbye&TestParam2=Testing parameter 2"); 

The code above is passing in the filepath to the report and the parameters that the reports takes.

The example below is a full working example.

 using System;
 using Gtk;
 
 public class GtkRdlViewerExample {
 
   public static void Main() {
     Application.Init();
 
     Window myWin = new Window("Gtk Sharp RDL Viewer Example ");
     myWin.Resize(800,800);
 
     RdlGtkViewer viewer = new RdlGtkViewer();
     viewer.LoadReport(new Uri(@"/home/peter/Projects/My-FyiReporting/Examples/SqliteExamples/SimpleTest3WithParameters.rdl"), 
         "TestParam1=Hello and Goodbye&TestParam2=Testing parameter 2"); 
 
     // Add the gtk sharp viewer to the form  
     myWin.Add(viewer);
    
     myWin.ShowAll();
 
     Application.Run();   
   }
 }

Requirements

Make sure to include RdlEngineConfig.xml and setup the path to the database provider assembly (see https://github.com/majorsilence/My-FyiReporting/wiki/Database-Providers-Howto)

You will need a reference to poppler-sharp.dll. On ubuntu install the package libpopplier-cil. There is one problem with this package; it does not show up in the reference list in MonoDevelop. So you will need to browse to the dll. On my system it was in\usr\lib\poppler-sharp\poppler-sharp.dll.

Monodevelop Gtk-Sharp RdlViewer Widget

MonoDevelop Gtk Rdl Widget

Cairo Render Backend

The cairo render code has been merged from the NReport project.

The nice thing about this viewer is it is a natively rendered with cairo. The downside at the moment is that it does not appear to support parameters.

using System;
using Gtk;

class MainClass
{
	public static void Main (string[] args)
	{
		Application.Init();
		
		Window myWin = new Window("Gtk Sharp RDL Viewer Example ");
		myWin.Resize(800,800);
		
		fyiReporting.RdlGtkViewer.ReportViewer viewer = new fyiReporting.RdlGtkViewer.ReportViewer();
		viewer.LoadReport(new Uri(@"/home/peter/Projects/My-FyiReporting/Examples/SqliteExamples/SimpleTest2.rdl"));

		// Add the gtk sharp viewer to the form  
		myWin.Add(viewer);
		
		myWin.ShowAll();
		
		Application.Run();   	
	}
}