.net - How to print text to bottom left corner in page in C# -
code below used print order. order can have variable number of lines written out first drawstring call.
text
bottom line1 bottom line2 must appear in bottom left corner in page.
code below uses hard coded value e.marginbounds.top + 460 print this. how remove hard-coded value text printed in bottom of page ?
var doc = new printdocument(); doc.printersettings.printername = "pdfcreator"; doc.printpage += new printpageeventhandler(providecontent); doc.print(); void providecontent(object sender, printpageeventargs e) { e.graphics.drawstring("string containing variable number of lines", new font("arial", 12), brushes.black, e.marginbounds.left, e.marginbounds.top); e.graphics.drawstring("bottom line1\r\nbottom line2", new font("courier", 10), brushes.black, e.marginbounds.left, e.marginbounds.top + 460); }
measure string, move height bottom?
void providecontent(object sender, printpageeventargs e) { e.graphics.drawstring("string containing variable number of lines", new font("arial", 12), brushes.black, e.marginbounds.left, e.marginbounds.top); string bottom = "bottom line1\r\nbottom line2"; font courier = new font("courier", 10); size sz = textrenderer.measuretext(bottom, courier); e.graphics.drawstring(bottom, courier, brushes.black, e.marginbounds.left, e.marginbounds.bottom - sz.height); }
Comments
Post a Comment