Questions tagged [drawstring]

Graphics.DrawString is a method in the .Net Framework's System.Drawing namespace, by which code can draw text onto an image in .Net code. This is mainly used in ASP.Net, as TextRenderer.DrawText (from System.Windows.Forms) provides more reliable functionality in Windows Forms applications.

313 questions
3
votes
2 answers

Write Text on Image ( Specified width )

I am generating ICards for employees. I have to write address of the employee on the ICard. Image blankICard = Image.FromFile(@"C:\Users\admin\Pictures\filename.jpg"); Bitmap outputImage = new Bitmap(blankICard.Width,…
Kishan Gajjar
  • 1,120
  • 3
  • 22
  • 43
3
votes
2 answers

How to draw a String inside a filled rectangle?

I just want to display my String inside a rectangle filled with black. Thanks for the help!
alicedimarco
  • 325
  • 1
  • 5
  • 20
3
votes
3 answers

Center drawn text

I'm drawing text in VB.net by using: gfx.DrawString(_bText, New Font("Tahoma", 5), Brushes.Black, New Point(25, 5)) where gfx is a graphics object using my control. The x point is correct but I need the y to be the center of the current contol…
Freesnöw
  • 30,619
  • 30
  • 89
  • 138
3
votes
1 answer

Graphics.DrawString doesn't draw last SPACE chars?

The string is "Hello World " with 10 SPACE chars in the end, but Graphics.DrawString in Right Alignment omits all of SPACE chars, it just draws "Hello World" only. protected override void OnPaint(PaintEventArgs e) { …
qtg
  • 125
  • 1
  • 11
3
votes
1 answer

gdi+ - Graphics.MeasureString either too wide or too narrow

I'm using the System.Drawing library in C# to measure a string's size: SizeF size = gfx.MeasureString("Hello", myFont); However, this returns a size with a bit of spacing around the text. Here's the text rendered with a red bounding box that…
Bip901
  • 590
  • 6
  • 22
3
votes
4 answers

Drawing "transparent" text via C# Graphics, but in a way that it turns the drawn text to be "missing" so it's transparent in the resulting image

I am looking to draw a string on a DC (Graphics - I am using C#) - but I want the drawn text to be "deleted" from the image so that what's left is essentially a cut-out of the text. If I was to DrawString with a transparent brush obviously nothing…
Shahar Prish
  • 4,838
  • 3
  • 26
  • 47
3
votes
1 answer

Create rectangle for the string that can be resized and center positioned

At first, I used drawString and GraphicsPath.AddString to draw outlined/solid text in the pictureBox. I can change it's font size, style and font-family but I realized that I won't be able to resized/stretch the text since the font size is…
TerribleDog
  • 1,237
  • 1
  • 8
  • 31
3
votes
0 answers

C# System.Drawing - DrawString method - arabic string issue

I have the following issue when trying to draw a string and then printing it to PDF by Amyuni Printer : where I couldn't select the text when pressing (Ctrl+A) , I need this PDF file to use it into another PDF reader , and it seems that the reader…
3
votes
2 answers

Graphics2D - identical text rendering on all platforms

Is it possible to render pixel-by-pixel identical result with Graphics2D.drawString on all java platforms with same font? I tried to render text without antialiasing, but results differs on different machines. I use font from project resources, so…
David E. Veliev
  • 134
  • 1
  • 8
3
votes
1 answer

Fix text stretching when printing to a receipt printer with Java

I am printing to some Epson receipt printers by implementing the Java Printable and placing my code into the print method. To draw the text to the printer I use Graphics2D.drawString. I am also drawing a rect to the printer to see how to compares to…
user469650
  • 51
  • 2
  • 4
3
votes
2 answers

C# VS2010: how to draw scrolling text using drawstring without flicker

I'll preface this by saying I've already tried a bunch of ways of achieving my goal and I'm now resting at the "best" solution, but it's still far from what I would consider "great"...so I was hoping to get a suggestion here. This is in C# using…
TrojanNemo
  • 117
  • 9
3
votes
0 answers

using delphi winapi drawstring

I'm working on using win api for delphi. I tried with DrawString procedure for over couple hours, but still can't get it right. Delphi keep gives me the message 'there is no overload version of 'DrawString' that can be called with these…
eesther
  • 57
  • 1
  • 7
3
votes
3 answers

Disable word breaking when wrapping lines in .NET DrawString

I am using .NET to draw a string into a limited space. I want the string to be as big as possible. I have no problem in the string breaking up into more lines (if it stays inside the rectangle). Now the problem: I don't want .NET to break the string…
HH321
  • 502
  • 1
  • 6
  • 20
3
votes
2 answers

Drawstring up to down textdirection right (like chinese old style)

I want to print using Graphics.DrawString() method but I want to print that up to down. For example I have string "Hello" and I want to be printed H e l l o With only one Graphics.DrawString() Is it possible or not? because I have dynamic length of…
rifleon
  • 105
  • 1
  • 1
  • 10
3
votes
1 answer

How do I turn off text padding inside layout rectangle performed by Graphics.DrawString?

When I write a string with Graphics.DrawString, passing a StringFormat object (carrying StringAlignment.Near) and a layout Rectangle, the text starts some number of pixels to the right of the edge of the Rectangle. This padding is related to size of…
sehrgut
  • 209
  • 1
  • 13