How to print data form C# - 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)

Related

c# printing PDF in Multiple setting output?

I have a .net application in c# where I'm trying to print using a pdf document on the left side and a text description on the right side. So far I've been successful in combining the 2 outputs into one pdf file, but am stumped on how to programmatically do it so that when I go to print, then in the Page Sizing & Handling section, select "Multiple" and set pages per sheet to 2.
My guess is it's a process print feature somewhere but can't seem to find any examples nor clear documentation to do so. Please advise, thanks.
if you want to set pages per sheet from the backend rather than print/ print dialog you have to use PrintTicket Class [System.Printing]. this classs have lots of property and events that can allow us to do lots of printing and printing job related stuff using c# code. there is also many classes related to printing in this name space[ may you know about the xps in windows when you going to print may you see option print to xps it is belongs to Print Schema class]
you can read more about it from https://msdn.microsoft.com/en-us/library/system.printing.printticket.aspx

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.

Programmatically printing dynamic tabular data using Visual Studio 2008 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.

Filling out a PDF / form using Winform application

I have a 2-page PDF that I want to overlay information on (think of a form that someone manually fills out) using a C#/.NET Windows application. After this form is generated, it will need to be previewed and printed (exported into a graphic or PDF is nice, but not a requirement).
At first glance, I'm thinking of two ways to do this:
Use a PDF manipulator like iTextSharp, take a copy of the blank PDF form, and add text to the PDF. Then, launch Adobe Reader to do a print or preview.
Convert the PDF into a graphic, and put the graphic into a C# Report. Then, overlay text fields onto the report, and use a .NET ReportViewer control to preview and print the report.
The text does not need to be searchable or copyable or have any of the cool things that PDF gives me, so I'm leaning towards the second option. Am I missing anything, or is there something I'm not thinking of? Thanks in advance.
We use #1 extensively and it works perfectly. You shouldn't have any problems, it's rather easy (just need to make the fields writeable and use a FDF file and merge it with the PDF file). At least that's how we did it.

Print simple numbers on label printer (Brother, Dymo, etc) from C# (.NET)

As part of a project I'm working on, I need to automate a label printer. It will be one of those inexpensive USB printers from Brother or Dymo (open to other suggestions). All it needs to do is print two numbers on one label.
The challenge is that I'm hoping to keep it ultra-simple in C#. It seems like the solution from Brother is antiquated, and the Dymo SDK is a little more complicated than what I would like. Both solutions require the end user to install the full blown application.
Do I have to suck it up and use the low-level COM solution provided by Dymo? Or has someone found a simpler way to print uncomplicated labels?
DYMO now has a very handy framework that can be used to create and print labels using templates or built in XML.
Here is the download:
http://sites.dymo.com/Support/Pages/ProductDetails.aspx?MainTab=1&Tab=1&ProductID=DYMOSDK(DYMO)
Here is the documentation:
http://www.labelwriter.com/software/dls/sdk/docs/DYMOLabelFrameworkdotNETHelp/html/N_DYMO_Label_Framework.htm
Install the labelmaker as a printer on the computer.
Then, use mail-merge from Excel to Word.
Create a spreadsheet with rows representing labels and columns representing pieces of information on that label.
Use mail-merge in MS Word using the spreadsheet as the data.

Categories

Resources