hi,
after some time and several attempts, but also thanks to your suggestions, I finally came to solve my request.
For those who need it. I am attaching the code:
<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace hasmorepages
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
PaperSize paperSize = new PaperSize("papersize", 90, 55);
int startnr = 0;
int itemperpage = 0;
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Font myfont1 = new Font("Arial", 16, FontStyle.Bold, GraphicsUnit.Point);
Font myfont2 = new Font("Arial", 4, FontStyle.Bold, GraphicsUnit.Point);
int beginnr = Convert.ToInt16(txt_startnr.Text);
int howmanynr = Convert.ToInt16(txt_qty.Text);
int endnr = beginnr + howmanynr;
float currentY = 10;
e.Graphics.DrawString(dateTimePicker1.Text, myfont2, Brushes.Black, 30, currentY);
currentY += 5;
while (startnr <= endnr)
e.Graphics.DrawString(startnr + "/" + txt_departmnt.Text, myfont1, Brushes.Black, 18, currentY);
currentY += 40;
startnr ++;
if (itemperpage < 0)
{
itemperpage += 1;
e.HasMorePages = false;
}
else
{
itemperpage = 0;
e.HasMorePages = true;
return;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
itemperpage = 0;
startnr = Convert.ToInt16(txt_startnr.Text);
{
printPreviewDialog1.Document = printDocument1;
((ToolStripButton)((ToolStrip)printPreviewDialog1.Controls[1]).Items[0]).Enabled = false;
printDocument1.DefaultPageSettings.PaperSize = paperSize;
printPreviewDialog1.ShowDialog();
}
}
private void button2_Click(object sender, EventArgs e)
{
itemperpage = 0;
startnr = Convert.ToInt16(txt_startnr.Text);
printDocument1.PrinterSettings.PrinterName = "Microsoft Print to PDF";
printDocument1.DefaultPageSettings.PaperSize = paperSize;
printDocument1.Print();
}
}
}