Reputation: 334
I am using PrintDocuemnt class to printing records.At run time I am providing fontsize but I getting small size of letter on printing paper.
Function 1:Which calling CreateCheckFormatForCheckWriter method with Details object objTCWLDetailLayout and Current selected object
List<Image> StringToPrint=new List<Image>;
Image objInput = objCWLayout.CreateCheckFormatForCheckWriter(objTCWLDetailLayout, objCWPrintCheck);
StringToPrint.Add(objInput);
Function 2:Which call method CreateCheckFormatForCheckWriter()
Image objCheckImage1 = null;
Graphics g = this.CreateGraphics(); // edited by jeet - assigned this.CreateGraphics()
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
Brush P = new SolidBrush(Color.Black);
Pen pen = new Pen(Color.Black);
Draw_Check8_StringCompName(objGlobalRulerbitmapData, g, P, i, objCWPrintCheck.ChkCompanyName);
Function 3:Call Draw_Check8_StringCompName() method
private void Draw_Check8_StringCompName(List<TCWLDetail> objGlobalRulerbitmapData, Graphics g, Brush P, int i, string strVal)
{
try
{
string fontFace = ("Vedana");
int fontSize = 6;
Font drawFont = new Font(fontFace, fontSize);
float XCB = horizontalRuler.ScaleValueToPixel(objGlobalRulerbitmapData[i].FX);
float YCB = verticalRuler.ScaleValueToPixel(objGlobalRulerbitmapData[i].FY);
// float YCB = verticalRuler.ScaleValueToPixel((objGlobalRulerbitmapData[i].FY <=(float) 0.1 ?(float) 0.325 : objGlobalRulerbitmapData[i].FY));
string sTemp = strVal;
g.DrawString(sTemp, drawFont, P, XCB, YCB);
}
catch (Exception ex)
{
CusException cex = new CusException(ex);
cex.Show(MessageBoxIcon.Error);
}
}
And Finally We set image on PrintDocument.StringToPrint is List type collection.
private void PrintDocument_PrintPage(Object sender, PrintPageEventArgs e)
{
try
{ //Set image from StringToPrint collection
e.Graphics.DrawImage(StringToPrint[PageCounter], 6, 12, 816, 1256);
//PageCounter++;
//e.HasMorePages = (PageCounter != StringToPrint.Count);
}
catch (Exception ex)
{
CusException cex = new CusException(ex);
cex.Show(MessageBoxIcon.Error);
}
}
Upvotes: 0
Views: 2038
Reputation: 1433
You're setting the PaperSize, not the actual font size itself. Either you didn't provide the code which draws the text on your PrintDocument
, or the font (type/size/etc) is never set. If you use Graphics.DrawString to draw text, you can set the font (and its size).
Upvotes: 1