Recently, there is a requirement in a project that requires one or more big texts, just like the ones in my graduation thesis. ArticleOutput to the printer. I have referred to many public libraries including codeproject. Source codeIn the codeproject CodeThe examples are for English text, but the method for measuring and calculating the size of Chinese strings using English code is not good, and text loss often occurs.
So I refer to a part of the Code on the codeproject and wrote the text printing code after I modified it again.
Function:
1 has three constructors: the non-parameter constructor, the string parameter constructor, and the stream parameter constructor, indicating that it can be a large string, obtain the content to be printed from a data stream.
2. You can define the number of lines printed per page.
3. You can customize the content of the header and footer.
4. Automatic printing and paging.
Disadvantages:
1. process the Chinese formatAlgorithmNot perfect yet. The line spacing during print preview is too close and ugly.
2. Unlike the word, the title and other content in the text cannot be processed with special font styles, that is, all printed text fonts are the same.
Click here to download