Programmatically printing dynamic tabular data using Visual Studio 2008 C# - c#

I am planning to write an application to automate generation of package slips. The idea is that the application would pick up customer order details from the database (say every morning) and generate package slips for them which could be printed out with the click of a button.
I would like to be able to either print one package slip per page or (in order to save on paper) maximum 2 (if there is enough space left to fit both). I would also prefer to have an option of print preview before printing.
The package slips use a table with some columns spanning over multiple columns above/below.
Not so important at this point, but a need may arise to be able to export the daily package slips generated by the application to word or PDF.
What is the best way to achieve this?

I'm not sure if it would work in your case. But most of what you are asking to do can be achieved using iTextSharp to generate a PDF file dynamically. Because it would generate a PDF you would get a lot of your requirements for free (such as printing, print preview etc). However, not sure about going from PDF to Word. Worth considering though as iTextSharp has good support for tabular data.

Related

Creating a complicated PDF in C#/MVC

This is .NET 4.6/MVC 5. I'm trying to create a rather complicated PDF in C#, but I can't quite figure out a good way to do so.
We use Kendo UI and it has PDF export capabilities (demos), but that requires creating a print layout with HTML/CSS. I was unable to figure out how to use #page with images in the header/footer.
We've used iTextSharp in the past, but it now requires a very expensive license for commercial use.
PDFsharp and MigraDoc (API) look nice, but they have almost no documentation and I've been unable to figure out how to use them.
How can I accomplish the task of creating a PDF in the format of the below screenshot? I don't need to be spoonfed, just given a general idea. I have no preference for or against any specific method, I just don't know what would work well.
This is the layout I'm attempting to create. The green lines separate the header/body/footer. The header and footer are the same on all pages. The table in the body will display data from a list--it needs to display only what can fit on a page, then move to the next page and the next items in the list.
Essential PDF can create complex PDFs with any custom layout. You can also create a template in Word and convert into PDF with your data merged in.
The entire product is available for free and can be used in commercial applications also (if the organization makes less than 1 million USD in annual revenue) through the community license.

ASP.NET c# Creating a PDF (both Rotativa and ITextSharp) how to modify the ViewerPreferences dictionary to turn off print scaling in adobe readier

We are generating PDFS from a web app a couple different ways, ItextASharp, Html->Rotativa, and RDLC...
Is there any way in anyof those tools to modify the ViewerPreferences dictionary inside the PDF so as to disable the "shrink to fit" option..
The PDF format supports this option, I've found documentation for that...
I'm aware that not all viewers honor the request not to shrink to fit, but we're using stock adobe readers across the board so it's ok.
I was able to find this in ITextSharp to read one, modify it and save, it, so I have to believe there is a way to set it before generation...but I can't find it..
Determine properties such as if PDF is Simplex or Duplex in iTextSharp
It'd be awesome if Rotativa had a way too...since we use that for some reports
We also have some done in RDLC style, if there is a way to do it there...
The reason we have to do it, is one of our apps prints labels and the amount of data leave no room for fudging it. Printing them from a web app is problematic, even when we control the ecosystem.
Unfortunately, our IT group will not use the reg settings to change the default on the machines.. we have to do it through code.

How to create a multiple page invoice in asp.net c#?

I am thoroughly confused with something I want to do and am looking for some advice.
One of my client has to produce monthly invoice detailing all of the company expenditure, and two other such invoices. The client is sure that he only needs these invoices - and they are extremely simple enough to produce as far as logic is concerned.
Now, to make the actual invoice, I don't really want to use reporting solutions like Telerik, SSRS etc.. as I think they are an overkill for my purpose. At the same time, I am not sure how I can get the printer to print the invoices in a neat pages without cutting off anything.
I am very tempted to just give the output in a webpage and ask my client to print them off from there.
Am I not looking at this the right way? Is this possible?
I could use ITextSharp or something to produce pdf's.. In fact, I think I will go ahead with this if it isn't possible to just output to html page and get the printer to recognize the page breaks somehow.
Because this is a very small job, I don't want to spend too much time on it as the cost of this freelance project is minimal too.
The reason printing to a new page is important is that my client has a few shops he deals with and he would want to print each of his customers their own invoices. I can get him to produce each customer's invoice separately and print them but it is not ideal way to deal with it.
thanks
There is a css property which should tell a browser to break a page: page-break-before.
But if you have a a wide list of browsers to support, it would be better to get some HTML to PDF conversion library or really use iTextSharp (as far as I know there is even a module/class which allows to conver HTML to PDF with iTextSharp) as printing web pages has many issues.
In the past, when I wanted to create a reusable document, I used Word or Excel XML formats.
See: http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
They are easy to create and tweak, then all you have to do is recreate the dynamic parts in your code. All you have to do is save the document in Office XML format, then open it up in word pad to see where to make your changes.
SSRS has a drag and drop interface for designing reports and has a PDF output option. If the data is in a SQL server database then even with the learning curve it should be easier to do SSRS reports.

How to print data form C#

I've searched Stackoverflow and google and found many ways
how I can print stuff in C#.
The best way for me would be to populate blank white windows form
with some label, textbox and picturebox elements and print it as a windows form.
This way is very poor because it prints in 72 DPI, and is not flexible for multiple
pages print.
Next way that I found that would be good is using iTextSharp, but there is a problem
that iTextSharp only generates PDF-s, and you have to open it in PDF viewer and print
from there.
I love this way of thinking where I create a paragraph, and then fill it with text and graphic, so I found this thread
http://www.devarticles.com/c/a/C-Sharp/Printing-Using-C-sharp/
where it discusses how to create your own printing engine in C#, something like iTextSharp,
but very lightweight...
Now that I've said that, I want to know is there any ready to use printing engine that would be like iTextSharp, made for printing, not for PDF generation? What is the best way to print something, without using reporting services like CrystalReports.
I think Crystal Reports wouldn't work for my case cause I don't want to print generic reports, but some text and graphics that I need to dynamicaly generate every time I need to print.
I found that it was much easier to do printing using the printing stuff in WPF.
EDIT
XPS is the page description format that Microsoft included into .NET with .NET 3.0. It is nominally part of WPF, and is integrated with the WPF form layout model. But you can create XPS documents in memory and send them to printers, from any .NET app, including a WinForms App.
An example:
http://statestreetgang.net/post/2008/03/Creating-an-XPS-document-in-memory-via-the-DOM.aspx
It is approximately equivalent to the iTextSharp capability you explored, except:
you can do it all in memory if you like, no need to save to a filesystem file. Of course if you want to save to a filesystem file, you can do that too.
you don't need an external viewer in order to start the print.
If you are new in programming and you have some data like from Data Base, and you want to print it after retrieving it from Data Base. Then just follow this link it will guide you step by step.
Print Data in Dot Net (C#,Vb.net)

Can Crystal Reports be edited in a .Net Windows interface?

I am currently evaluating Crystal Reports 2008 for use within a major enterprise project. I have successfully used Crystal Reports Basic within Visual Studio, but we want more functionality. Can these reports be edited in a .Net Windows interface?
Reports will be produced based on ADO.NET Xml datasets and will be saved to a SQL Server db as blobs of the rpt files. We will be retrieving these rpt files for viewing within a .Net Windows application coded using Visual Studio 2008 in C#.
I need to produce letters that hide and show sections/paragraphs based on formulae, but the users want to be able to edit the text.
Once a report has been created and is being displayed within the .Net CrystalReportViewer control (inside a .Net Windows application), is there any way I could permit the user to alter the displayed text and re-save the rpt file?
I know that I can use parameters, but it's not ideal for large paragraphs of text which may include some words in bold for example. The users are only likely to be changing a few words, such as the addressee of the letter. They have insisted that they need to be able to change anything on the letter.
I also know that (with Crystal XI or 2008) I can export to EditableRTF which does not put the text in frames like the standard RichTextFormat export option. The .Net RichTextBox component does not show headers or footers, which is a pain. I can show the RTFs in Word (even though they miss out lines and boxes from the report, but that's another matter) but quite frankly I'm terrified of the stories of deploying Office interop components in .Net apps.
When Crystal displays a report in preview mode you can click on pararaphs and it knows that there is a 'field' there because it highlights the row(s) with a box. Is there any way we can just edit this text and save the report again?
I'm under pressure to produce an estimate for this area of work. Is it possible within Crystal?
You've got a really good handle on the capabilities of Crystal, and you're right - the idea of editing big chunks of report text "live" is going to be tough.
The "export to RTF" option might be workable, provided you can live with one-way generation (after you use Crystal to generate the report and start editing the output, you can't re-generate without losing your edits).
Have you considered something like OneNote or other XSLT-based solutions? It seems like your users want a lot of control over the generated output, so your design's going to have to factor that in. Maybe even generate output and then shoot it straight into a document management system so users' changes are tracked and controlled?

Categories

Resources