Click here to Skip to main content
15,882,744 members
Home / Discussions / C#
   

C#

 
Questionfolder path syntax? Pin
Anonymous15-Mar-04 3:32
Anonymous15-Mar-04 3:32 
AnswerRe: folder path syntax? Pin
John Fisher15-Mar-04 4:15
John Fisher15-Mar-04 4:15 
AnswerRe: folder path syntax? Pin
Dave Kreskowiak15-Mar-04 7:05
mveDave Kreskowiak15-Mar-04 7:05 
Questionhow can i run client software from web? Pin
agakyurek15-Mar-04 3:15
agakyurek15-Mar-04 3:15 
AnswerRe: how can i run client software from web? Pin
Heath Stewart15-Mar-04 5:14
protectorHeath Stewart15-Mar-04 5:14 
GeneralPrinting a blank page Pin
Shaun Becker15-Mar-04 2:47
Shaun Becker15-Mar-04 2:47 
GeneralRe: Printing a blank page Pin
John Fisher15-Mar-04 4:13
John Fisher15-Mar-04 4:13 
GeneralRe: Printing a blank page Pin
Shaun Becker15-Mar-04 4:36
Shaun Becker15-Mar-04 4:36 
Here is the code. Thanks alot


public IntPtr CreateFont(IntPtr hDC, string fontName, int size, FontStyle style)
{
LOGFONT lf = new PrinterApi.LOGFONT();
FONT_WEIGHT_FLAGS weight = FONT_WEIGHT_FLAGS.FW_DONTCARE;

if (Convert.ToBoolean(style & FontStyle.Bold)) {
weight |= FONT_WEIGHT_FLAGS.FW_BOLD;
}

if (Convert.ToBoolean(style & FontStyle.Regular)) {
weight |= FONT_WEIGHT_FLAGS.FW_REGULAR;
}

lf.lfHeight = (-1) * GetFontSize(hDC, size);
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = weight;
lf.lfItalic = Convert.ToByte(style & FontStyle.Italic);
lf.lfUnderline = Convert.ToByte(style & FontStyle.Underline);
lf.lfStrikeout = Convert.ToByte(style & FontStyle.Strikeout);
lf.lfOutPrecision = CHARACTER_PRECISION.OUT_TT_ONLY_PRECIS;
lf.lfClipPrecision = CLIP_PRECISION.CLIP_DEFAULT_PRECIS;
lf.lfPitchAndFamily = (byte)FONT_PITCH.DEFAULT_PITCH | (byte)FONT_FAMILY.FF_DONTCARE;
lf.lfFaceName = new byte[LF_FACESIZE];

byte[] temp = Encoding.ASCII.GetBytes(fontName);
for (int i = 0; i < lf.lfFaceName.Length; i++) {
if (i >= temp.Length) {
lf.lfFaceName[i] = 0;
} else {
lf.lfFaceName[i] = temp[i];
}
}
return CreateFontIndirect(ref lf);
}

int GetFontSize(IntPtr hDC, int size)
{
return size / 72 * GetDeviceCaps(hDC, LOGPIXELSY);
}

public void Method()
{
string Text = "Some Text";

IntPtr hDC = CreateDC(null, @"Network Imagistics im3510 PCL5e", null, 0);
DOCINFO doc = new PrinterApi.DOCINFO();
doc.cbSize = Marshal.SizeOf(typeof(DOCINFO));
doc.lpszDocName = "Test Win32Printer";
doc.lpszOutput = null;

if (StartDoc(hDC, doc)) {
StartPage(hDC);

try {
RECT rectStruct = new PrinterApi.RECT();
rectStruct.Left = 0;
rectStruct.Top = 0;
rectStruct.Right = 600;
rectStruct.Bottom = 600;
IntPtr font = CreateFont(hDC, "Times New Roman", 20, 0);
IntPtr oldFont = SelectObject(hDC, font);
DrawText(hDC, Text, Text.Length, ref rectStruct, DRAWTEXT_FORMAT_FLAGS.DT_NOCLIP);

SelectObject(hDC, oldFont);
DeleteObject(font);
EndPage(hDC);
EndDoc(hDC);
} catch (Exception e) {
AbortDoc(hDC);
throw e;
} finally {
}
}

DeleteDC(hDC);
}
GeneralRe: Printing a blank page Pin
John Fisher15-Mar-04 6:09
John Fisher15-Mar-04 6:09 
GeneralRe: Printing a blank page Pin
Shaun Becker15-Mar-04 8:21
Shaun Becker15-Mar-04 8:21 
GeneralRe: Printing a blank page Pin
Shaun Becker15-Mar-04 9:25
Shaun Becker15-Mar-04 9:25 
GeneralRe: Printing a blank page Pin
John Fisher15-Mar-04 16:55
John Fisher15-Mar-04 16:55 
GeneralCheckbox in Subitem of ListView Pin
katetsai15-Mar-04 2:44
katetsai15-Mar-04 2:44 
GeneralRe: Checkbox in Subitem of ListView Pin
Heath Stewart15-Mar-04 5:11
protectorHeath Stewart15-Mar-04 5:11 
GeneralRe: Checkbox in Subitem of ListView Pin
katetsai15-Mar-04 5:58
katetsai15-Mar-04 5:58 
GeneralRe: Checkbox in Subitem of ListView Pin
Heath Stewart15-Mar-04 6:14
protectorHeath Stewart15-Mar-04 6:14 
GeneralRe: Checkbox in Subitem of ListView Pin
John Fisher15-Mar-04 6:15
John Fisher15-Mar-04 6:15 
GeneralRe: Checkbox in Subitem of ListView Pin
Heath Stewart15-Mar-04 6:31
protectorHeath Stewart15-Mar-04 6:31 
GeneralLocalizing standard types in PropertyGrid Pin
i_blazhko15-Mar-04 1:49
i_blazhko15-Mar-04 1:49 
GeneralRe: Localizing standard types in PropertyGrid Pin
Heath Stewart15-Mar-04 5:10
protectorHeath Stewart15-Mar-04 5:10 
GeneralRe: Localizing standard types in PropertyGrid Pin
i_blazhko15-Mar-04 22:42
i_blazhko15-Mar-04 22:42 
GeneralRe: Localizing standard types in PropertyGrid Pin
Heath Stewart16-Mar-04 2:48
protectorHeath Stewart16-Mar-04 2:48 
GeneralRe: Localizing standard types in PropertyGrid Pin
i_blazhko16-Mar-04 3:04
i_blazhko16-Mar-04 3:04 
GeneralGet the true icons of a file Pin
Jonathan Slenders15-Mar-04 0:29
Jonathan Slenders15-Mar-04 0:29 
GeneralRe: Get the true icons of a file Pin
SimonS15-Mar-04 0:56
SimonS15-Mar-04 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.