c# - How to print many graphical objects in a loop? -
i have print lot of barcodes. how can in loop, if use code block print single barcode:
p.printpage += delegate(object sender1, printpageeventargs e1) { e1.graphics.drawstring("title", new font("univers 55", 6), new solidbrush(color.black), new rectanglef(titlex, titley, p.defaultpagesettings.printablearea.width, p.defaultpagesettings.printablearea.height)); e1.graphics.drawstring(s, new font("barcode", 24), new solidbrush(color.black), new rectanglef(codex, codey, p.defaultpagesettings.printablearea.width, p.defaultpagesettings.printablearea.height)); e1.graphics.drawstring(test, new font("univers 55", 8), new solidbrush(color.black), new rectanglef(numberx, numbery, p.defaultpagesettings.printablearea.width, p.defaultpagesettings.printablearea.height));
};
titlex, titley, codex, codey, numberx, numbery variables store position of 3 parts of each barcode object (title, stripes , number), should alter in loop.
if want print multiple barcodes on single page, nothing stopping putting in loop. move code separate method though, instead of "inline delegate", keep clean:
p.printpage += printpage; ... private void printpage(object sender, printpageeventargs e) { (int = 0; < numberofbarcodes; i++) { int titley = * titleydistance + titleyoffset; // etc. e.graphics.drawstring(...); // etc. } }
if have more fit on single page, printpageeventargs
class has hasmorepages
property. event method called long keep setting property true
, allowing print different barcodes each page.
Comments
Post a Comment