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

Introduction

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.

Enjoy!

License

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

Share

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]http://www.ryushinkan.co.uk/[/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 22:38 
GeneralTechnical adaptation to a CEditView derived SDI application PinmemberRaymond_Gimilio8-Feb-10 20:35 
GeneralPage setup PinmemberTariqZ5-Jun-07 19:33 
GeneralFaster method (Great article Btw) PinmemberY_R1-Feb-07 9:55 
QuestionPage Breaks Using MFC 6.0+ Pinmemberomar6314-Nov-06 9:27 
GeneralMultiple print job Pinmembervivadotnet12-Aug-04 11:59 
Generalconstructing long string... Pinmembervivadotnet8-Jul-04 6:01 
GeneralRe: constructing long string... PinsussAtewar22-Jul-04 10:44 
GeneralRe: constructing long string... Pinmembervivadotnet31-Jul-04 12:00 
GeneralCEditView and CString PinmemberThe_Inventor21-Jun-04 20:14 
GeneralRe: CEditView and CString Pinmembertom-kaltofen30-Jan-06 23:37 
GeneralWord Wrap PinmemberGerard Lim31-May-04 3:00 
Generalthanks a lot Pinmemberabicer27-Apr-04 22:06 
GeneralPrint question Pinmembernikoladsp13-Jan-04 6:19 
GeneralPrinting to a Printer/Help Pinmembermelshehu16-Oct-02 5:58 
GeneralRe: Printing to a Printer/Help PinmemberRoger Allen17-Oct-02 2:37 
GeneralRe: Printing to a Printer/Help Pinmembermelshehu17-Oct-02 5:54 
GeneralJust what I was looking for PinmemberDylan Kenneally24-Jul-02 1:17 
GeneralRe: Just what I was looking for PinmemberRoger Allen24-Jul-02 3:06 
GeneralGood job. PinmemberShog920-Jun-02 17:59 
GeneralRe: Good job. PinmemberRoger Allen20-Jun-02 22: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
Web01 | 2.8.141030.1 | Last Updated 20 Jun 2002
Article Copyright 2002 by Roger Allen
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid