Click here to Skip to main content
Click here to Skip to main content

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

, 19 Jun 2002 CPOL
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.

Comments and Discussions

QuestionThank u! Pinmembersally899821-Jun-11 23:38 
GeneralTechnical adaptation to a CEditView derived SDI application PinmemberRaymond_Gimilio8-Feb-10 21:35 
GeneralPage setup PinmemberTariqZ5-Jun-07 20:33 
GeneralFaster method (Great article Btw) PinmemberY_R1-Feb-07 10:55 
QuestionPage Breaks Using MFC 6.0+ Pinmemberomar6314-Nov-06 10:27 
GeneralMultiple print job Pinmembervivadotnet12-Aug-04 12:59 
Generalconstructing long string... Pinmembervivadotnet8-Jul-04 7:01 
GeneralRe: constructing long string... PinsussAtewar22-Jul-04 11:44 
GeneralRe: constructing long string... Pinmembervivadotnet31-Jul-04 13:00 
GeneralCEditView and CString PinmemberThe_Inventor21-Jun-04 21:14 
GeneralRe: CEditView and CString Pinmembertom-kaltofen31-Jan-06 0:37 
GeneralWord Wrap PinmemberGerard Lim31-May-04 4:00 
Generalthanks a lot Pinmemberabicer27-Apr-04 23:06 
GeneralPrint question Pinmembernikoladsp13-Jan-04 7:19 
GeneralPrinting to a Printer/Help Pinmembermelshehu16-Oct-02 6:58 
GeneralRe: Printing to a Printer/Help PinmemberRoger Allen17-Oct-02 3:37 
GeneralRe: Printing to a Printer/Help Pinmembermelshehu17-Oct-02 6:54 
GeneralJust what I was looking for PinmemberDylan Kenneally24-Jul-02 2:17 
GeneralRe: Just what I was looking for PinmemberRoger Allen24-Jul-02 4:06 
GeneralGood job. PinmemberShog920-Jun-02 18:59 
GeneralRe: Good job. PinmemberRoger Allen20-Jun-02 23:47 

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

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

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