Is there a way to ignore page feed for thermal printers while using the PrintDocument
? In terms of printing a "receipt", if there are a lot of items on it (100's) the printer always puts a blank space between items where it thinks there should be a page feed.
My problem is there is no pages to feed, it's a continuous roll of paper.
In the printer drivers, via right clicking printer -> Printer Preferences -> Document Settings Tab; I have set the Paper Source to Page[NoFeed,Cut]
and Document[NoFeed,Cut]
but I still have the same issue.
I have also tried setting a "User Defined Paper Size" but it seems the EPSON drivers do not support this. My idea here was that I would just set the page height very long. Edit I have been able to try setting the printer to use a form that is 3276.00cm long but I still have the same issue. I have also tried setting the printer up as a generic printer and I still see the same issue
Here is the code I am using, perhaps there is a way to do this on the fly, in code?
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
// Sets the value of charactersOnPage to the number of characters
// of stringToPrint that will fit within the bounds of the page.
e.Graphics.MeasureString(pageString, this.Font,
e.MarginBounds.Size, StringFormat.GenericTypographic,
out charactersOnPage, out linesPerPage);
// Draws the string within the bounds of the page
e.Graphics.DrawString(pageString, this.Font, Brushes.Black,
e.MarginBounds, StringFormat.GenericTypographic);
// Remove the portion of the string that has been printed.
pageString = pageString.Substring(charactersOnPage);
// Check to see if more pages are to be printed.
e.HasMorePages = (pageString.Length > 0);
}
private void metroButton2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 200; i++)
{
pageString += "Salesitem " + i.ToString() + " \n";
}
bool online = printDocument1.PrinterSettings.IsValid;
if (online)
printDocument1.Print();
else
MessageBox.Show("Printer Offline");
}
Thank you very much for your time. I have seen some similar questions on SO, but most that I can understand rely on using the driver to solve this issue. This is not applicable for me because I have two requirements from my boss their driver for my printer and older models does not support creating custom page sizes directly from within the driver, nor does it seem to work for disabling the page feed. I need a way to solve this issue via code if possible.
Edit: I feel like I have tried everything. I have tried sending the data to the printer in chunks, but the problem is, every time printDocument1_PrintPage
is executed by checking e.HasMorePages = (pageString.Length > 0);
, the page feed command or line feed command is being sent to the printer (TMT 88IV, TMT 88II) even though in the driver I have it set to a roll of paper.
I have also tried using a custom paper kind, and starting with a small paper height, and dynamically adding to the paper height every time I draw a line, but still, it's like the paper height set in code and by the printer driver (it's set to be 3276.00cm long in the driver) is ignored every time the page event is raised.
The only way I have been able to get around this is using the RawPrinterHelper class, and send the print commands myself. Yes this is easy but I would love to be able to easily use the .net features for fonts, picture printing, queue monitoring ect. It's a shame, literally the only thing stopping me is this tremendous spacing automatically inserted on continuous roll paper on receipts longer than standard page height.