Click here to Skip to main content
14,976,129 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 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,

            stringToPrint = stringToPrint.Substring(charactersOnPage);

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

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

            printPreviewDialog1.Document = printDocument1;
Updated 11-Jan-18 3:19am
OriginalGriff 9-Jan-18 3:58am
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-

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