I want to print list of images on paper.for this I have used PrintDocument Class.
When I give print, It will printing only first page.
After that I made one line as
e.HasMorePages = true;
Then Its countineously printing on pages,even though I haven't much data,Images are repeating every time.
Below is my code.
When I insert e.HasMorePages=True;, it keeps on printing even though I passed two or three images.
private void PrintPage(object o, PrintPageEventArgs e
{
List<eanbarcodeprintsourcemodel> EANBarcodePrintList = new
List<eanbarcodeprintsourcemodel>();
if (Session["Print"] != null)
{
int count = 50;
EANBarcodePrintList = Session["Print"] as List<eanbarcodeprintsourcemodel>;
for (int i = 0; i < EANBarcodePrintList.Count; i++)
{
string labelData = EANBarcodePrintList[i].ItemCode + " " +
EANBarcodePrintList[i].StyleNo + " " +
EANBarcodePrintList[i].PlatingCode + " " +
EANBarcodePrintList[i].ColourCode;
string MRPAmount = "MRP." +
EANBarcodePrintList[i].ProductMRPAmount.
ToString("N", new CultureInfo("te-IN"));
e.Graphics.DrawString(labelData,
new Font("Tahoma", 7),
Brushes.Black,
new PointF(50, 40 + (count + 50 + (i * 50))));
count += 30;
e.Graphics.DrawImage(EANBarcodePrintList[i].NormakBarcodeImage,
50,
count + 70 + (i * 50), 150, 40);
count += 20;
e.Graphics.DrawString(EANBarcodePrintList[i].NormakBarcode,
new Font("Tahoma", 7),
Brushes.Black,
new PointF(90, 40 + (count + 50 + (i * 50))));
count += 30;
e.Graphics.DrawImage(EANBarcodePrintList[i].EanBarcodeImage,
50,
count + 70 + (i * 50), 150, 40);
count += 20;
e.Graphics.DrawString(EANBarcodePrintList[i].EANBarcode,
new Font("Tahoma", 7),
Brushes.Black,
new PointF(90, 40 + (count + 50 + (i * 50))));
count += 10
e.Graphics.DrawString(MRPAmount,
new Font("Tahoma", 7),
Brushes.Black,
new PointF(110, 40 + (count + 50 + (i * 50))));
count += 30;
}
}
Can you please suggest Where I should put e.HasMorePages=true and e.HasMorePages=false; in above code?
Thanks in advance,
Kiran