Output as Browser (C#)
Set up and configure output to a browser from your reporting application. The Browser option provides high fidelity viewing. Silent printing is not available; you must use the Print function in your browser.
Example
This code snippet uses the
BrowserViewer
class:// code snippet starts
String designFile = "OrderReport.4rp";
//Defining renderer object:
LayoutedPagesConsumer renderer = null;
//Send report to Genero Web Viewer:
BrowserViewer viewer = new BrowserViewer();
String uuid = Guid.NewGuid().ToString();
String webRootDirectory = Directory.GetCurrentDirectory() + "\\..\\..\\HTTPDaemon";
viewer.documentDirectory = webRootDirectory + "/reports/" + uuid;
viewer.fontDirectory = webRootDirectory + "/reports/fonts";
viewer.fontFileFormat = BrowserViewer.FontFileFormat.woff;
if (httpd == null)
{
httpd = new Process();
String greDir = Environment.GetEnvironmentVariable("GREDIR");
OperatingSystem OS = Environment.OSVersion;
String extension = (Environment.OSVersion.Platform == PlatformID.Unix
|| Environment.OSVersion.Platform == PlatformID.MacOSX) ? "" : ".bat";
httpd.StartInfo.FileName = greDir + Path.DirectorySeparatorChar + "bin"
+ Path.DirectorySeparatorChar
+ "grehttpd" + extension;
httpd.StartInfo.Arguments = "-p 6403 -d \"" + webRootDirectory + "\"";
httpd.StartInfo.UseShellExecute = false;
httpd.StartInfo.CreateNoWindow = true;
httpd.StartInfo.RedirectStandardInput = true;
httpd.Start();
}
// code snippet ends
In this example:
- An object named
renderer
is defined using theLayoutedPagesConsumer
class. - A
viewer
object is defined using theBrowserViewer
class. - The String variables
uuid
andwebRootDirectory
are created and set. - The
documentDirectory
,fontDirectory
andfontFileFormat
properties configure for the browser viewer. - The
if
statement specifies the lightweight web server to use and the URL to attempt.
Note:
This is from the OrderReport demo, and uses our lightweight web server. You can find the complete code in the demo.
For the full list of properties and methods for this renderer class, refer to the Genero Report Writer .NET API documentation.