2009-04-07 2 views
0

サーマルプリンタLIPI LWT 150に印刷するにはC#.netとGDIの印刷コードを使用していますが、フォントサイズを変更できません。 Arial 9ptと5ptを使用していますが、デフォルトサイズで表示されます。 誰もこれについて考えていますか?C#.netを使用してサーマルプリント(lipi lwt 150)でフォントサイズを変更する方法

私はこのようなC#のコードを使用しています:それは、任意のフォント、2つだけ作り付けの固定幅フォントをサポートしていないように見えるprinter specificationに基づいて

public frmSale() 
     { 
      InitializeComponent(); 
      printingDoc.PrintPage += new PrintPageEventHandler(Form_PrintPage); 
     } 

//initalizing print document 
private void PrintSettings() 
{ 

    printingDoc.DefaultPageSettings.Margins = new Margins(3, 3, 3, 3); 
    PaperSize pSize = new PaperSize(); 
    pSize.Width = 275; 
    printingDoc.DefaultPageSettings.PaperSize = pSize; 

    // Claculating the PageWidth and the PageHeight 
    PageHeight = printingDoc.DefaultPageSettings.PaperSize.Height; 
    PageWidth = printingDoc.DefaultPageSettings.PaperSize.Width; 
    // Claculating the page margins 
    LeftMargin = printingDoc.DefaultPageSettings.Margins.Left; 
    TopMargin = printingDoc.DefaultPageSettings.Margins.Top; 
    RightMargin = printingDoc.DefaultPageSettings.Margins.Right; 
    BottomMargin = printingDoc.DefaultPageSettings.Margins.Bottom; 
    printAreaWidth = PageWidth - RightMargin - LeftMargin; 

} 

private void Form_PrintPage(object o, PrintPageEventArgs e) 
//Here we Begin All the printing Process... 
{ 

     PrintSettings(); 
     CurrentY = (float)printingDoc.DefaultPageSettings.Margins.Top;//0; 
     PrintEstHeader(e.Graphics); 
     DrawEstGridData(e); 

} 

//Printing Function 
private void PrintEstData(Graphics g, string stringData, StringAlignment alignment, Font fnt, Color clr, bool newLine)//,int starting,int maxWidth) 
{ 
    StringFormat stringFormat = new StringFormat(); 
    stringFormat.Trimming = StringTrimming.Word; 
    stringFormat.FormatFlags = StringFormatFlags.NoWrap | 
     StringFormatFlags.LineLimit | StringFormatFlags.NoClip; 

    stringFormat.Alignment = alignment; 

    RectangleF Rect = new RectangleF((float)LeftMargin, CurrentY, 
         (float)PageWidth - (float)RightMargin - (float)LeftMargin, 
         g.MeasureString(stringData, fnt).Height); 

    g.DrawString(stringData, fnt, 
     new SolidBrush(clr), 
     Rect, stringFormat); 

    CurrentY += newLine ? g.MeasureString(stringData, fnt).Height : 0; 
} 

private void PrintEstHeader(Graphics g) 
{ 

    PrintEstData(g, "----------------------------------------------", StringAlignment.Near, new Font("Arial", 9), Color.Black, true);//,LeftMargin,printAreaWidth); 

    PrintEstData(g, "Estimate" + " " + "Rate :" + ncRate.Value.ToString("0.00"), StringAlignment.Near, new Font("Arial", 9, FontStyle.Bold), Color.Black, true);//, LeftMargin, 76); 

    PrintEstData(g, "----------------------------------------------", StringAlignment.Near, new Font("Arial", 9), Color.Black, true);//, LeftMargin, printAreaWidth); 
    PrintEstData(g,"|ITEM |"+"WEIGHT|"+ "STN WT|"+"M.C. %|"+"Total|", StringAlignment.Near, new Font("Arial", 5), Color.Black, true);//,LeftMargin,42); 
    PrintEstData(g, "----------------------------------------------", StringAlignment.Near, new Font("Arial", 9), Color.Black, true);//, LeftMargin, printAreaWidth); 
} 

答えて

0

。プリンタにビットマップを印刷したり、ユーザーの文字を作成したりすることができない限り、フォントAまたはフォントBを選択する以上のことができるかどうかは疑問です。

+1

答えでリンクが壊れています。 –

関連する問題