How do I Change the font of the text in a Button Control - epplus

I am using EPLUS to create a button and I would like to change the font and font size of the text in the button. How do I do it?

Try something like this
button.Font = new Font("Microsoft Sans Serif", 10);

Related

VB.NET Textboxes come out fuzzy upon converting to a Bitmap image

My application acts as a document template with textboxes for users to fill in. Once they've completed, they can "print" the document to a PDF using PDFsharp. This is done by converting the panel on which the textboxes are on to a bitmap image using the code below;
ConditionReportConfig.PG1.Panel2.DrawToBitmap(Bitmap, New Rectangle(0, 0, Bitmap.Width, Bitmap.Height))
frm_MsgPrint.lbl_Page.Text = "Page: 1" : frm_MsgPrint.lbl_Page.Refresh()
frm_MsgPrint.PictureBox1.Image = Bitmap
frm_MsgPrint.PictureBox1.Refresh()
BXImage = Bitmap
GFX.ScaleTransform(0.82)
GFX.DrawImage(BXImage, 25, 0)
GFX.Dispose()
CDR1 = Nothing
Unfortunately, when the PDF pops up with the image the entire image, more so the text in the textboxes, are fuzzy. They aren't fuzzy to the point you can't read, but they do make reading the text incredibly stressful on your eyes.
I've tried adding various settings in such as;
Dim Bitmap2 = New Bitmap(894, 1367)
Using G As Graphics = Graphics.FromImage(Bitmap2)
G.InterpolationMode = Drawing2D.InterpolationMode.Bicubic
G.DrawImage(Bitmap, 0, 0, 120, 150)
End Using
I've even tried changing the font, size, even saving the bitmap as a TIFF, PNG and it still appears fuzzy. I would change printing methods, but the whole point of the panel is to be printed. Not only that but the panel contains images so I can't just print the text on the PDF.
Edit:
I've tried changing some of the interpolation settings, and it is slightly clearer but still a strain on your eyes.
Below is a snippet of the Bitmap image as a TIFF. Notice how the text in the textboxes is "Fuzzy" but the vertical text alongside is perfect. Is there really no way of getting textbox contents to be as sharp as the vertical text?
Blurry image with crystal clear vertical text:
Create an XImage from your bitmap and set
image.Interpolate = false;
for that image. This is a hint for Adobe Reader not to smooth the image.
Also check that ClearType does not make your image blurry before adding it to the PDF.

How to change TextBox.text font style to Italic

I have a textbox control called tb_remarks ,tried to make texts written in tb_remarks using
tb_remark.Font.Italic = True but getting read only exception.
Note : I don't want to change control's property using designer
Use the Font-constructor and assign it to the textbox:
Dim font = New Font(tb_remark.Font, FontStyle.Italic)
tb_remark.Font = font
By passing the old Font you use all other properties as prototype.
You should initialize new style for the font as per Control.Font Property and assign italic-style
tb_remarks.Font = New Font(Font, FontStyle.Italic)

How can I cause values assigned to PdfFormField TextFields to be black instead of gray?

I am generating a PDF that populates the PDFFormFields with the values inputted by the user in a Sharepoint 2010 WebPart, like so:
PdfPCell cellPaymentAmountTextBox = new PdfPCell()
{
CellEvent = new DynamicTextbox("textBoxPaymentAmount"),
Phrase = new Phrase(boxPaymentAmount.Text, timesRoman9Font)
};
tblFirstRow.AddCell(cellPaymentAmountTextBox);
("boxPaymentAmount" is a Textbox control on the WebPart)
It's working pretty well, except that the values inputted appear gray instead of black on the PDF file:
How can I get these to be black instead of gray?
I am using a font that is declared as black, not gray:
Font timesRoman9Font = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, BaseColor.BLACK);

iTextSharp - PDF field contents become invisible

I have a PDF where I add some TextFields.
var txtFld = new TextField(stamper.Writer, new Rectangle(cRightX - cWidthX, cTopY3, cRightX, cTopY), FieldNameProtocol) { Font = bf, FontSize = cHeaderFontSize, Alignment = Element.ALIGN_RIGHT, Options = PdfFormField.FF_MULTILINE };
stamper.AddAnnotation(txtFld.GetTextField(), 1);
The ‘bf’ above is a Unicode font that gets embedded in the PDF:
BaseFont bf = BaseFont.CreateFont(UnicodeFontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // Create a Unicode font to write in Greek...
Later-on I fill those fields with greek text.
var acrof = stamper.AcroFields;
acrof.SetField(fieldName, field.Value/*, field.Value*/); // Set the text of the form field.
acrof.SetFieldProperty(fieldName, "setfflags", PdfFormField.FF_READ_ONLY, null); // Make it readonly.
When I view the PDF, most of the times the text is missing and if I click on the (invisible) TextField in Acrobat, then the text becomes visible (until it loses focus again).
Any idea what is going on here?
I have also tried using non-embedded font, but I get the same thing (although I still seem to get embedded fonts in PDF that are similar to the font I use). I don't know if I am missing sth.
It seemed that I was doing the following at the wrong order (the following is the correct):
acrof.SetFieldProperty(field.Name, "setfflags", PdfFormField.FF_READ_ONLY, null); // Make it readonly.
acrof.SetFieldProperty(field.Name, "textfont", bf, null);
acrof.SetField(field.Name, field.Value/*, field.Value*/); // Set the text of the form field.
At least that's hat I think it was wrong.
I have made many changes.

Is there a way to resize an MdiTab to fit your newly-updated text? (Infragistics)

I am resetting the text for an MdiTab in an UltraWinTabbedMdi. I reset it to be bold and longer, but the tab does not resize so the text is truncated. Right now, I'm just resetting the size of the tab to some magic number that I've found looks decent on my computer, but I don't know if it will work elsewhere. I would like to be able to get the dimensions of the new text and add the same size to that every time or call some auto-resize method.
Is there a way to do this?
You could use the MeasureString of the Graphics class.
// Set up string.
string measureString = "YourText";
// The font name and size used to draw the string (from your MdiTab)
Font stringFont = new Font("Arial", 16);
// Measure string.
SizeF stringSize = new SizeF();
stringSize = this.Graphics.MeasureString(measureString, stringFont);
// now you have a stringSize.Width and stringSize.Height to use