簡單文字列印,PrintDocument使用

2021-05-22 20:15:28 字數 3520 閱讀 8581

using system;

using system.text;

using system.drawing;

using system.drawing.printing;

using system.windows.forms;

using system.io;

namespace textprinter

頁"; }

/// /// report title

///

public

string title

set

} /// /// report context string

///

public

string context

set

} /// /// report context font

///

public font font

set

} /// /// report title font

///

public font titlefont

set

} /// /// report title type

///

public titletype titletype

set

} /// /// report footer type

///

public footertype footertype

set

} /// /// report footer format. etc "第頁"

///

public

string footerformat

set

} //public int totalpage

////}

/// /// report row padding. 行間距

///

public

int rowpadding

set

} /// /// 初始化列印

///

private

void initprint()

/// /// 印表機設定

///

public

void printsetting()

/// /// 紙張設定

///

public

void pagesetting()

/// /// 預覽報表

///

public

void preview()

/// /// 列印報表

///

public

void print()

/// /// read a line from buffer,

///

///

///

private

string getline()

if (m_leftcontext.substring(0, i).indexof("/n", 0) >= 0)

}tmp = m_leftcontext;

m_leftcontext = string.empty;

return tmp;

}finally

}/// /// internal print method

///

///

///

private

void internalprintpage(object sender, printpageeventargs e)

if (titletype == titletype.allpage)

top += drawtitle(e.graphics);

while (top < m_printablearea.height - (int)math.floor(m_wordsize.height))

if (footertype != footertype.none)

drawfooter(e.graphics);

e.hasmorepages = m_leftcontext != string.empty;

m_currentpage++;

} /// /// print report title

///

///

///

private

int drawtitle(graphics g)

/// /// print report footer

///

///

private

void drawfooter(graphics g)

of ", m_currentpage, 0);

sizef size = g.measurestring(tmp, systemfonts.defaultfont);

drawstring(g, tmp, systemfonts.defaultfont, systembrushes.windowtext,

new rectangle(m_printablearea.x, m_printablearea.bottom - (int)size.height,

m_printablearea.width, (int)size.height), stringalignment.far, stringalignment.center);

} /// /// draw a string with alignment parameter

///

///

///

///

///

///

///

///

private

void drawstring(graphics g, string s, font font, brush brush, rectangle rect, stringalignment alignment, stringalignment linealignment)

public

static

void preview(string pstr)

";//textprinter.printsetting();

//textprinter.pagesetting();

textprinter.preview();

//textprinter.print();

} public

static

void print(string pstr)

";//textprinter.printsetting();

//textprinter.pagesetting();

//textprinter.preview();

textprinter.print();

}} public

enum titletype

public

enum footertype

}

node列印彩色文字

字型顏色 30 37 console.log 033 30m 黑色字 033 0m 黑色 console.log 033 31m 紅色字 033 0m console.log 033 32m 綠色字 033 0m console.log 033 33m 黃色字 033 0m console.log ...

python 列印彩色文字

單獨使用 print 033 32 1m 我愛你,033 0m我很好。print 033 35 1m 我愛你,033 0m我很好。print 033 36 1m 我愛你,033 0m我很好。print 033 41 1m你好麼,033 0m我很好。print 033 42 1m你好麼,033 0m我...

UITextField實時列印輸入的文字

需要設定uitextfielddelegate,並且實現如下方法 bool textfield uitextfield textfield shouldchangecharactersinrange nsrange range replacementstring nsstring string 每當...