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.
Related
I have a timetable in memory, and need to be able to print it out.
The timetable will likely be many pages, each page will look quite similar:
A grid of cells, across the horizontal axis is time, and along the vertical axis is entities. Cell x, y will contain the allocation of a particular job to entity x at timeslot y.
I'm looking at the System.Drawing.Printing.PrintDocument class but it's incredibly cumbersome. I need to set an event handler to the PrintDocument.PrintPage, yet there doesn't appear to be any way to get the page number from the PrintPageEventArgs?
I just want to construct my document and call some Print() function. I suppose if I could get the page number within the event handler, I could construct the page layout on the fly with e.Graphics and GDI.
I could potentially even put together a HTML page using tables and print that - if I could somehow control what prints on what page?
Is there a better way to construct and print documents in C#?
The target machines do have Office installed, but they're all different versions and I've had lots of trouble getting correct versions of the .Net/Office interop library to work with them.
Edit: I could potentially even create a temporary LaTeX file on the fly and compile it, then print it. This seems like a good solution, except that the target machines are locked and the users can't install new software, hence I would need to bundle the LaTeX compiler with my program, and my compiler is almost 300MB.
Sounds to me like you're giving up too soon. Handling the PrintPage event isn't that difficult and since the event is raised sequentially, all you have to do is keep a page counter in that event. That's how I've done it in the past with MetaFile images (printing Reporting Services reports through a web service call).
I build a similar tool by using the Microsoft Chart Controls, easy to use.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&displaylang=en
If you can save it to a file, you can use this here,
Print images c#.net
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
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?
I have a textbox and a button in one page.I want to enter a word in the textbox and click the button. After clicking the button I want to display the name of the web pages containing the word entered in the textbox. So please tell me how to do it? I am using C#.
So you want to create a search engine internal to your website. There are a couple of different options
You can use something like google custom search which requires no coding and uses the google technology which I think we all agree does a pretty good job compared to other search engines. More information at http://www.google.com/cse/
Or you can implement it in .net which I will try to give some pointers about below.
A search engine in general exists out of (some of) the following parts:
a index which is searched against
a query system which allows searches to be specified and results shown
a way to get documents into the index like a crawler or some event thats handled when the documents are created/published/updated.
These are non trivial things to create especially if you want a rich feature set like stemming (returning documents containing plural forms of search terms), highlighting results, indexing different document formats like pdf, rtf, html etc... so you want to use something already made for this purpose. This would only leave the task of connecting and orchestrating the different parts, writing the flow control logic.
You could use Lucene.net a opensource project with a lot of features. http://usoniandream.blogspot.com/2007/10/tutorial-implementing-lucenenet-search.html explains how to get started with it.
The other option is Microsoft indexing service which comes with windows but I would advice against it since it's difficult to tweak to work like you want and the results are sub-optimal in my opinion.
You are going to need some sort of backing store, and full text indexing. To the best of my knowledge, C# alone is not enough.
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.