I am developing an application using C# which is simply the user inputs data, it is saved in a db (which is not SQL Server but MySql) and then prints it.
At this stage the user gave me a template which has the logo and some company information on top, in the middle the lines i need to fill and on the bottom some other information regarding this company.
Is it possible to open this document fill the required lines and print it using c#?
Sorry i cannot provide anything but i am stuck here and can't seem to figure out from where to start?
Thanks & Regards
Do you have access to any kind of reporting ie.Crystal Reports or SQL Server Reporting Services. You have one of 2 options, either you need to write a report that mimics his template using one of the technologies above, or you would need to use interops to access MSWord or MSExcel and do it that way. You may be able to use some third party PDF software.
If this was my project I would go the report route.
Related
I'm running an asp.net 4 / c# site using SQL Server 2005 and want to write column values from within SQL Server into a PDF file which already has content inside it (I want to personalise a PDF voucher that you get from the logged in page on my site)
Is there an easy tutorial to look at or is this a much bigger job?
There are two parts here:
Read data from database (for example, using ADO.NET, Entity Framework, e.t.c.)
Write that data to a PDF document (using some free or commercial PDF tool, like iTextSharp, SharpPDF, XPDF, Docotic.Pdf, e.t.c)
You can look at this article that describes both parts in detail.
Well, I think you have several options out there.
For example, you can create a PDF document based on a template using iTextSharp.
In that case, the template is the existing voucher you mention. You'd have to replace the information inside it, by identifying the fields, or something like that.
Something similar could also be accomplished using PDFSharp.
Just pay special attention when using iTextSharp to its license agreement, since its AGPL, which means your software must be GPL/AGPL as well.
Now, if you want to avoid interacting with PDF objects, and APIs, you have one other alternative. Which is to create an RDLC local report, and directly export it to PDF from your codebehind. In this case, it wouldn't be based on an existing voucher, it would be created from scratch.
I know this is a little subjective, but I'm looking into the following situation:
I need to produce a number of documents automatically from data in a SQL Server database. There will be an MVC3 app sat on the database to allow data entry etc. and (probably) a "Go" button to produce the documents.
There needs to be some business logic about how these documents are created, named and stored (e.g. "Parent" documents get one name and go in one folder, "Child" documents get a computed name and go in a sub-folder.
The documents can either be PDF or Doc(x) (or even both), as long as the output can be in EN-US and AR-QA (RTL text)
I know there are a number of options from SSRS, Crystal Reports, VSTO, "manual" PDF in code, word mail merge, etc... and we already have an HTML to PDF tool if thats any use?
Does anyone have any real world advice on how to go about this and what the "best" (most pragmatic) approach would be? The less "extras" I need to install and configure on a server the better - the faster the development the better (as always!!)
Findings so far:
Word Mail Merge (or VSTO)
Simply doesn't offer the simplicity, control and flexibility I require - shame really. Would be nice to define a dotx and be able to pass in the data to it on an individual basis to generate the docx. Only way I could acheive this (and I may be wrong here) was to loop through controls/bookmarks by name and replace the values...messy.
OpenXML
Creating documents based on dotx templates, even using OpenXML is not as simple as (IMHO) it should be. You have to replace each Content control by name, so maintenance isn't the simplest task.
SSRS
On the face of it this is a good solution (although it needs SQL Enterprise), however it gets more complicated if you want to dynamically produce the folders and documents. Data driven subscription gets very close to what I want though.
Winnovative HTML to PDF Convertor*
This is the tool we already have (albeit a .Net 2.0 version). This allows me to generate the HTML pages and convert those to PDF. A good option for me since I can run this on an MVC3 website adn pass the parameters into the controllers to generate the PDF's. This gives me much finer-grained control over the folder and naming structures - the issue with this method is simply generating the pages in the correct way. A bonus is that it automatically gives me a "preview"...basiclly just the HTML page!
Office OpenXML is a nice and simple way of generating office files. XSLT's can be strong tool to format your content. This technology will not let you create pdf's.
Fast development without using any third party components will be difficult. But if you do consider using a report server, make sure to check out BIRT or Jasper.
To generate pdf's I have been using the deprecated Report.net. It has many ports to different languages and is still sufficient to make simple pdf's. Report.net on sourceforge
I dont think SQL Server itself can produce pdf files. What you can do is, as you mentioned, install an instance of SSRS and create a report that produces the information you need. Then you can create a subscription to deliver your report to where you want, when you want.
Here is an example of a simple subscription:
Go for SSRS only if you are OK with setting it up on a server and there is a definite need for schedule reporting and complex reports.
If you have code for manual PDF/docx generation, I would suggest to go ahead with it. Hopefully the complexity of its code is not a matter to you.
I have used both in separate scenarios. We used excel classes and objects from .NET for a minimal reporting from a web application.
But went for an elaborate reporting scheme for a system which required 1000s of reports to be generated in a scheduled manner and delivered to selected set of people.
I work on some project that is migrating from vb6 to web (asp.net). I need to print some kind of report - A table from database and number of simple headers with date and time. In vb it was implemented using vsPrinter object. Is there any Class in C# that is similar to this Class in vb6 in its functionality? If there in no such thing in .net, what is the easiest way to do this?
Thanx for assistance!
Remember you are moving to the web so you don't have access to the hardware printer controls. You only have access to what the browser gives you. If you are not doing anything fancy with this you can do one of two things.
Since this is an ASP.NET webpage, simply create a new browser or popup and render your report as html. The user can them choose print from the browser print dialog or you can launch it with some generated javascript.
Use the Microsoft Report and Report Viewer controls is you need more formal report layout. These are available from your toolbox under the category Reporting.
I think the easiest way would be by using any reporting tool, one of the powerfull tools is Crystal reports, just google it an you will find alot of useful tutorial such as:
Creating Crystal Reports using C# with Datasets.
Crystal reports in ASP.NET
You can also find alot of useful threads about it here in SO under Crystal Reports tag, like:
How to use Crystal Reports with ASP.NET?
C# Crystal Reports Tutorial on asp.net?
I'm writing a program that will (among other things) print out labels with variable information. I want to be able to format these labels (preferably in a GUI) at design-time, then have them print out at runtime. What tools/languages/projects can I use to accomplish this?
The label needs to include text and also Code39 or Code128 barcodes.
Printing will be done on a normal default printer, or possibly a label printer, unknown at this time.
Preference is for open-source, free projects, but any suggestions are appreciated. I'd also like to be able to distribute the program through xcopy, meaning no separate installations needed on the client.
EDIT: I'm now trying to do this using Microsoft Reporting services in local mode, but I'm still having problems getting the barcode to be readable.
There is a simple walkthrough of using our programmable ActiveReports product to do this here. Once you design the labels you can get them in PDF or print them directly (among other things). Another example of using ActiveReports to create a label maker program is here. That one uses the ActiveX/COM edition of ActiveReports but the concepts are still the same in the C#/.NET version.
We also provide a product named Data Dynamics Reports that uses a page-based metaphore for designing reports rather than the banded metephore like ActiveReports. It includes a label wizard which you can find out more about at this link.
Scott Willeke
GrapeCity inc.
Using Microsoft Reporting Services I can use a local report. Its not xcopy, but it is free and relatively easy. I just have to install report viewer on the client (and the barcode font), then I can even run the .exe from a network share.
Well, heres my scenario.
Client/Server winforms application with SQL Express as the DB. I need to be able to print invoice, packing slips etc..
i would like the customer to be able to modify the invoices. ie. be able to put their logo or change font sizes etc...basically format the display.
Things i have considered so far are.
1) Use a template engine (similar to codesmith or mygeneration) and use templates that output HTML. Then print the html page.
2) Use ReportViewer in local mode. I've heard that users can download a plugin for web dev express and edit the local report files. can anyone confirm this?
3) Use Reportviewer in remote mode.
I don't have much experience with ReportViewer so I'm not sure if i should use local or remote mode as well.
Those of you that have done this kind of thing before whats your recommendation?
After just completing a project with it, I would heartily recommend iTextSharp to create your invoices and other forms as PDFs. In addition to creating PDFs from scratch, you can also use it to fill in PDF forms and/or templates created with Acrobat (or even MS Office/OpenOffice). And it's free.
It's pretty easy to use in Windows apps or in ASP.Net applications. Most of the documentation and the books on it (iText in Action, for example) are about the original Java version, iText. However, there are tutorials and example code on the conversion process and, for the most part, all of the functions and libraries work the same in the .Net version, so adapting the book and reference code has been no problem.
I definitely learned the hard way that HTML and CSS are great for browsers (well, great except for the "every browser interprets it different" problem), but horrible for trying to generate consistent, attractive, and precise printed output and forms.
I'm personally using Aspose Words: they use word documents as templates, and I'm using Words bookmarks function to mark and retrieve the fields I need to fill.
Aspose works nicely with Tables (ie: you can add lines to a table, etc...) and sees Word documents as XML documents. You can then save the document as MSWord or PDF.
I wouldn't say it's the greatest library in the world, but it's definitely worth having a look :)
you can use Crystal Report for this. But first you need to scan the INVOICE and save it as an image,
Next is, on your crystal report, export the image on to it, and DRAG the fields to where they must print on the invoice (IMAGE SERVES AS YOUR GUIDE). Then after everything has been set-up, DELETE THE IMAGE and try it.
hope this helps.