Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my billing application, I can print the bill in pdf format but I need to convert the data of the bill to be printed in image format All the data are added through string builder how do i do this

What I have tried:

>var printText = new PrintText(sb.ToString(), new Font(System.Drawing.FontFamily.GenericMonospace, 9, System.Drawing.FontStyle.Bold));
                    Graphics graphics = e.Graphics;
                    int startX = 0;
                    int startY = 0;
                    int Offset = 20;

graphics.DrawString(printText.Text,newFont(System.Drawing.FontFamily.GenericMonospace, 9, System.Drawing.FontStyle.Bold),
        new SolidBrush(System.Drawing.Color.Black), startX, startY + Offset);
                    Offset = Offset + 20
Posted
Updated 2-Jun-22 6:02am
Comments
Ralf Meier 2-Jun-22 8:29am    
you want to have your graphic with more than one String in it ...?
or do you want to print your string inside an area with more than one line ? For example like this :
this is
my string

1 solution

In WPF, you print or save from a "visual"; which can be derived from controls, user controls and windows. Or you can use a "drawing visual".

How to: Create a Bitmap from a Visual - WPF .NET Framework | Microsoft Docs[^]

DrawingVisual Class (System.Windows.Media) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900