Question

I am using the code template from Microsoft at this site with this snippet to print out only a single line and form feed:

string s = "Hello world!\xC"; //\xC means form feed
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
    RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s);
}

But no luck, my paper size long is always like A4 paper size long.

What is wrong with my code? Do anyone got a hint or trick to deal with this problem?

Was it helpful?

Solution

It's hard to say what the problem might be. SendStringToPrinter ultimately ends up calling WritePrinter, which is supposed to copy what you send it to the printer unchanged. A form feed is supposed to advance the paper vertically to the beginning of the next page. "Next page" in this case is defined by the printer, and the printer's configuration will say how long a page is.

Are you perhaps wanting to advance just one line by using a line feed?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top