I want to print some formatted text using C#. the text is something like this:
Hi i am a Multi-line partially formatted text. I want to be printed using C#(winforms). I might contain some unicode text like مرا به هیچ بدادی و من هنوز بر آنم/ که از وجود تو مویی به عالمی نفروشم and so on....
I tried C# System.Drawing
printing, but it was very hard and very messy, so I searched and found PDFsharp which can draw multi style text and create a PDF from it. It says in the first page that:
PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer
but I don’t see how?
I don’t want to create a PDF file and print it. also I don’t want to make a pagePreview
that I don’t use.
Is there a way to print directly from XGraphics
or whatever? How?
Is there a better alternative(and free, because I am broke :( ) to PDFsharp?
(a simple "helloworld" sample would be very nice)
You can create an XGraphics object from a Graphics object:
XGraphics gfx = XGraphics.FromGraphics(graphics, size);
So if you have a Graphics object for a printer, you can use PDFsharp code for printing.
Not sure if it can be of help for you, as the Graphics object can be used for printing directly.
Using XGraphics makes sense if you need PDF and printing or PDF and screen preview.