Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is regarding dot matrix printing in c#:
Problem description :-

Report Title would be bold, Report title will repeat all the pages.page will scroll
to new page if there is no printable content.

What I have tried:

public void ReadFile()
        {
            documentContents = File.ReadAllText(FilePath);
            stringToPrint = documentContents;
        }
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {

            int charactersOnPage = 0;
            int linesPerPage = 0;

           
            e.Graphics.MeasureString(stringToPrint, this.Font,
                e.MarginBounds.Size, StringFormat.GenericTypographic,
                out charactersOnPage, out linesPerPage);

           
            e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
           110,10);

           
            stringToPrint = stringToPrint.Substring(charactersOnPage);

            
            e.HasMorePages = (stringToPrint.Length > 0);

           
            if (!e.HasMorePages)
                stringToPrint = documentContents;
        }
        private void btnPreview_Click(object sender, EventArgs e)
        {
            ReadFile();

            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();
        }
    }
Posted
Updated 11-Jan-18 3:19am
v2
Comments
OriginalGriff 9-Jan-18 3:58am    
And?
What did it do that you didn't expect, or not do that you did?
What help do you need?

1 solution

Try these following urls, may be help you-
https://whitefiles.org/b1_s/1_free_guides/fg2cd/pgs/c03c_prntr_cds.htm
http://stanislavs.org/helppc/epson_printer_codes.html
https://en.wikipedia.org/wiki/ESC/P
https://www.codeproject.com/Articles/29709/Line-Printer-Class-in-C
https://www.codeproject.com/Articles/29709/Line-Printer-Class-in-C
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900