How to write a simple designer for printed reports - c#

I'm currently having a couple of reports which I print from my Forms applications.
However building printed reports only with the built-in .NET printing methods is very tedious. Even just printing a simple table on a couple of pages with a little bit of formatting is a task for a couple of hours (if it should look nice).
What I need is a WYSIWYG-Designer for the layouts, so I'd like to write one.
It shouldn't be for End-Users, but for me as a developer, it's just about to create the layout what the report will look like with various arrangements/fonts/images/formats and so on and not have to do that by trial & error in code (and restart the app a zillion times).
So my specific questions:
What would I use as a canvas for editing and display of the report? An image-control/bitmap which I draw upon like on the printed document? Is there a better way?
Is drawing on a form comparable to drawing on a printed page? What about differences in resolution printer vs. screen?
How to get real WYSIWYG? Should I get the printer settings and create my canvas with the same resolution? Is there something else to consider?
I know that there are report designers around but I think it's sometimes good to understand the basic working principles of what you use and implementing them is for me the best way to do that.
I'm aware that this is not a specific question A to which the answer is always B, but if it were that way I would find an answer in Google pretty quickly.
Thanks in advance!

I can't say much about designing a WYSIWYG editor, but I have written a few custom in-house reporting engines for use by our development team.
There's two main ways I've created reports. The first is using PDFsharp (MIT-licensed) to manually layout pages which isn't for the faint-of-heart.
The second is using Winnovative's HTML to PDF library (not free, but royalty-free) which uses the current installed version of IE to do the layout and spit out a PDF. It looks like they've recently released a new version called EVO PDF which I have never used before.*
For the HTML to PDF solution, it supports JavaScript so you can add in charts from JavaScript libraries like flot or jqplot.
*I'm not affiliated with Winnovative.

You might want to save time and use Visual Studio HTML designer as your WYSIWYG editor.
What I'm currently doing is using ASP.NET MVC 3 as a simple reporting engine. You can use the MVC pattern to really separate your reporting data source (Model) and the rendering (View) while using Visual Studio as your report designer.
From your application you can easily call your actions with the report optional parameters. For example:
http://localhost/Report/Customer/Orders/1
You simply get the returning string from a WebClient's DownloadString method and you have your report generated.
There is some down side using HTML, mainly the difficulties to know when a page would break, but by using code in your View you can calculate the amount of repeating items and add a CSS break-page and re-starting your table's header on the next page.
You can achieve anything from graphics, to table, you can even generate link to other reports.
HTH.

Printing Reports in Windows Forms
http://msdn.microsoft.com/en-us/library/ms996472.aspx

Related

Charting tool that generate on memory

My question seems confusing but I'll let you explain it more clearly. Me and my team we're currently developing a complex report that comprises of words, tables and charts. As of now we generate this report by using a word document template and filling it up with the model we have. As for chart this is where it becomes complicated, we have two application that we're using in business one is a windows/wpf application and a web application. Both application uses the same engine we have for generating chart (ComponentOne) but the engine itself is only compatible for windows application. We use the assembly we generate from windows/wpf application on our web application for us to generate a report.
Our report generator on website will only have filter and parameters on what kind of report they want to generate and on a press of button. What do you think will be the best to tackle this issue so that we can drop using the assembly we have. We don't like to drop using template for this as these greatly help us on maintaining the report when changes is required the only thing that we think right now on how can we generate a chart on memory and convert it into an image so that we can dump it on our template.
It's not confusing, it's just not clear at all. If I get it right you just have a reporting tools ComponentOne that make reports on software side and it's not adapated for web side.
You somewhat tried to tackle it by using software dll in your website and it doesn't work as well as you expected/wanted. And you keep trying as of now.
Your question is basicly "How can I use a dll designed for software into a website?"
And the answer is simple. It's case by case when not outright impossible.
I invite you to look for another solution than using a software designed dll on a website. Even your idea of putting it inside an image is somewhat bad (lose of all controllers / defeat of the purpose of an interactive report.)
I'm pretty sure that ComponentOne would have think of such a problem as web reports and maybe even a solution to link web reports to soft reports. With a little search, I found a C1WebReport and even found some forums talking about C1Report to C1WebReport. Does it answer your problem?

C# Organize Data Onto a Print Template

Ok I've tried this in every possible combination... I know this can be done in Access, so I know it can be done in C#...
What I'm trying to do is set up a print button, that when clicked, organizes data from various controls on my form into specific positions on a predefined template. Like say I'm generating a Job Estimate, and I want to print it... It would look silly printing the control or form, so I'd like it organized into a neat standard format on a page, that may include a logo etc. I don't want the data exported to a document, I just want the print button to auto-generate this so that it can be printed from the application.
Can anyone point me to some resource that deals with this? I have googled my mind away, and searched all over stack overflow, but I'm not even sure what the correct wording to look something like this up with is, as it keeps giving me c++ or some other random stuff to look at that has nothing to do with what I am looking for....
What you are looking for is a reporting tool, which can render a structured report to screen, or to print or to a file format like PDF.
Many reporting tools exist for .Net development, Crystal Reports, Active Reports, Reporting Services in SQL Server.

Using an editor like FckEditor in a form application

I am working on a contract management system on c# form application, one of the main parts of the project is to create a letter.
In this part of the application a user can send a letter with in the shape he or she wants, so I need an editor like FCK in html, because my users should be able to insert table insert image and etc.
Any idea how to get this working? Any concerns?
You could indeed use a HTML WYSIWYG editor, but depending on the quality of it, it might raise problems when converting the output of it to print. This may also depend on the framework used to generate the Word document.
In one of our environments, we use CKEditor and JasperReports. That combination is suitable to export to Word, since JasperReports supports reading HTML and convert that to Word.
However, the best solution may depend on your business requirements and personal preferences.
If the application is a business application, another option is to let them edit the document in Word. Our company (disclaimer: I am biased) has build a product that supports editing a Word document from a template loaded and filled from a database (or multiple databases). However, if it is useful to you depends on your business requirements.
FCK is history now and as mentioned by others CKEditor is the successor. TinyMCE would be another alternative, or any other might be..
But what I want to mention is along with possible printing issues (that I have never dealt with) I want to underline another aspect:
my users should be able to insert table insert image and etc.
uploading and inserting images might be another issue...they don't come with a built in uploader, they sell it. you have the option to buy CKFinder along with CKEditor and Moxiemanager along with TinyMCE unless you choose to handle upload and insert into the editor process yourself.

Replicate Printed Form With Web Form

I'm hoping people have some ideas to help solve this problem.
I am developing a C# ASP.NET website and the client requires an online form that users will fill in and submit. OK, so far so good.....
Imagine, say, a form that you fill in on paper - they normally have a distinctive look specific to the company and will be filed, quite possibly as a legally binding document.
I need to have an online form that when submitted emails the client with something they can print out and will look exactly like their printed forms.
As this is web based, I think the option of capturing a screenshot are out the question, so I'm wondering how best to approach this?
Even if I just had a form that captures the data presented how I want, how could I translate this data into the view they want?
Any ideas and suggestions greatly appreciated.
You'll need to take the raw data that was submitted and import it into a standard document (likely PDF). You can use Crystal or another reporting solution, or direct to PDF using one of the many PDF .NET solutions that are out there.
I don't think you'd even want to deal with making the document physically match the screen - much easier to make the web look like the web, and make the printed doc look like a printed doc.
Print a page (this one) from a Browser, notice all the headers and footers?
If you want serious control over how it is going to look, you will need to generate a PDF (or maybe XPS).
Couldn't you just use a sepparate page with a CSS that gives the desired look & feel?

How to restrict download options on a single report in SSRS?

This question asks how to restrict for a whole server. I just want to do so for a single report. I found a code snippet but it doesn't provide any clues on how to implement:
foreach (RenderingExtension extension in this.reportViewer.LocalReport.ListRenderingExtensions()) {
if (extension.Name == "PDF") {
((Extension)(extension.GetType().GetField("m_serverExtension", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(extension))).Visible = false;
}
I can't see how to make the report reference this code upon loading. Does anyone know how I am supposed to make the report execute this code?
EDIT: Incidentally report access is through the SSRS Report Manager web app. We are, in the main, delighted with this product so wouldn't consider reinventing the wheel in order to implement a hack to produce what is, essentially a "would be nice" feature.
It still boggles the mind slightly that the report's available rendering options are not controllable at the report level. Ho hum.
Incidentally I found this blog entry which clarifies the above code a little. Turns out we're talking about using a reportviewer component to limit the export options. Apparently this requires a dirty, dirty hack and besides it's not how we want to run our reporting function.
So unless anyone has a better idea than this within the next fortnight I'll mark this as the answer which basically sums up to:
You can only restrict functionality like this under certain conditions and by no means easily even when you do.
This seems like a clear failure in the wider fitness of SSRS for purpose as we have users who require Excel export functionality and users who need to be limited to PDF only. Oh well.
Does it matter?
Once they've downloaded the data and taken it offsite, you've lost it anyway.
You haven't really described how you are calling the reports - have you created some kind of application? Are you actually using the report viewer control?
You can generate a report in a specific format using the report URL and including the rs:Format parameter, e.g.
http://SERVER/reportserver?%2fSomeFolder%2fSomeReport&rs:Command=Render&rs:Format=PDF
The above URL generates the report as a PDF. You can also use the URL to hide the report toolbar etc. so you could create these URLs as links in your application, maybe one using just rs:Command=Render as a "View Report" link and one link that includes rs:Format=PDF as an "Export to PDF" link.
More on Reporting Services URL access.

Categories