Click here to Skip to main content
13,044,584 members (61,003 online)
Click here to Skip to main content
Add your own
alternative version


25 bookmarked
Posted 19 Jun 2002

Example of how to print a long CString across multiple pages of output using the MFC print architecture

, 19 Jun 2002
Rate this:
Please Sign up or sign in to vote.
An example project of how to break up a long string that you want to print across multiple pages

Sample Image - Preview.jpg


A common question in the forums in the past has been how do I break up a long string and print it using the standard MFC architecture. Above is an example project that does just that. You can enter a long string to print in a MultiLine edit control. To see what the output would be like for your printer, you can select the Print Preview option from the file menu.

There are some drawbacks in the example in that is doesn't handle tabs correctly as it only uses CDC::TextOut() when printing, and CDC::GetTextExtent() when measuring whether the currently selected line will fit in one line, or needs to be broken up across multiple lines. This can be changed by yourselves as a programming extercise using the CDC::DrawText()function.

I hope this example will help out beginners at printing.



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


About the Author

Roger Allen
Software Developer (Senior) Sirius Analytical Instruments
United Kingdom United Kingdom
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.

I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)

I am also a keep fit fanatic, doing cross country running and am seriously into [url][/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

You may also be interested in...


Comments and Discussions

QuestionThank u! Pin
sally899821-Jun-11 22:38
membersally899821-Jun-11 22:38 
GeneralTechnical adaptation to a CEditView derived SDI application Pin
Raymond_Gimilio8-Feb-10 20:35
memberRaymond_Gimilio8-Feb-10 20:35 
GeneralPage setup Pin
TariqZ5-Jun-07 19:33
memberTariqZ5-Jun-07 19:33 
GeneralFaster method (Great article Btw) Pin
Y_R1-Feb-07 9:55
memberY_R1-Feb-07 9:55 
QuestionPage Breaks Using MFC 6.0+ Pin
omar6314-Nov-06 9:27
memberomar6314-Nov-06 9:27 
GeneralMultiple print job Pin
vivadotnet12-Aug-04 11:59
membervivadotnet12-Aug-04 11:59 
Generalconstructing long string... Pin
vivadotnet8-Jul-04 6:01
membervivadotnet8-Jul-04 6:01 
GeneralRe: constructing long string... Pin
Atewar22-Jul-04 10:44
sussAtewar22-Jul-04 10:44 
GeneralRe: constructing long string... Pin
vivadotnet31-Jul-04 12:00
membervivadotnet31-Jul-04 12:00 
GeneralCEditView and CString Pin
The_Inventor21-Jun-04 20:14
memberThe_Inventor21-Jun-04 20:14 
GeneralRe: CEditView and CString Pin
tom-kaltofen30-Jan-06 23:37
membertom-kaltofen30-Jan-06 23:37 
GeneralWord Wrap Pin
Gerard Lim31-May-04 3:00
memberGerard Lim31-May-04 3:00 
Generalthanks a lot Pin
abicer27-Apr-04 22:06
memberabicer27-Apr-04 22:06 
GeneralPrint question Pin
nikoladsp13-Jan-04 6:19
membernikoladsp13-Jan-04 6:19 
GeneralPrinting to a Printer/Help Pin
melshehu16-Oct-02 5:58
membermelshehu16-Oct-02 5:58 
GeneralRe: Printing to a Printer/Help Pin
Roger Allen17-Oct-02 2:37
memberRoger Allen17-Oct-02 2:37 
GeneralRe: Printing to a Printer/Help Pin
melshehu17-Oct-02 5:54
membermelshehu17-Oct-02 5:54 
GeneralJust what I was looking for Pin
Dylan Kenneally24-Jul-02 1:17
memberDylan Kenneally24-Jul-02 1:17 
GeneralRe: Just what I was looking for Pin
Roger Allen24-Jul-02 3:06
memberRoger Allen24-Jul-02 3:06 
GeneralGood job. Pin
Shog920-Jun-02 17:59
memberShog920-Jun-02 17:59 
GeneralRe: Good job. Pin
Roger Allen20-Jun-02 22:47
memberRoger Allen20-Jun-02 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 20 Jun 2002
Article Copyright 2002 by Roger Allen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid