use win32 API the print rtf and doc

Posted on 2002-04-03
Last Modified: 2012-06-21

I want to use win32 API to write to print rtf or word doc.
can anyone nhelp me. (i use addjob, setjob, createfile but it just can print text file)

Question by:DouglasKwong
LVL 10

Accepted Solution

makerp earned 50 total points
ID: 6917481
you will need to either,

learn the word doc format and write binary files using that...


use the word active x control from within your code to create word docs, that will be much easier and less prone to error, especially if the word format changes with new releasees of word

LVL 12

Expert Comment

ID: 6917507
You don't need the Word activeX control at all. If all you need to do is handle RTF files, and the formatting of said files isn't too complex, I suggest you investigate the RichEdit control--this is capable of reading and writing RTF files and allowing full control over the editing of these files.

In point of fact, the WordPad wordprocessor which ships with many versions of Windows is little more than a wrapper window around a RichEdit control, so you can test out the functionality of the control for yourself before you ever start testing code!
LVL 49

Expert Comment

ID: 6917595
MFC provides a class, CRichEditView.  It can printout the formatted RTF.  You can use AppWizard to create a simple SDI app, with the default view set to CRichEditView.  It even provides a Print Preview feature because the excellent programmers at Microsoft though that would be nice.

If you don't want to use MFC, you can trace into the code to see what it is doing and then use the relevant portions (at some leve, MFC is just a bunch of calls to Win32 APIs).  As I recall there is some tricky business involved in calculating the page sizes and so forth.

-- Dan
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

LVL 86

Expert Comment

ID: 6917773
Hmm, why don't you just use

ShellExecute ( NULL, "print", "c:\\path\\myfile.doc", NULL, NULL, SW_HIDE);


ShellExecute ( NULL, "print", "c:\\path\\myfile.rtf", NULL, NULL, SW_HIDE);

LVL 12

Expert Comment

ID: 6920206
DanRollins: CRichEditView is just a wrapper round a RichEdit control, as it happens. You can use RichEdit controls the same way you do edit controls, no need for MFC at all.
LVL 49

Expert Comment

ID: 6920293

>> no need for MFC at all.

I see that you are unfamiliar with MFC and/or the CRichEditView.  MFC handles the very thing that DouglasKwong desires: a way to print out a hardcopy of the formatted RTF.  It does this by providing a LOT of code to make it happen.  Pagination alone is a major headache.

The RicheEdit common control does not provide any of that capability.

-- Dan
LVL 11

Expert Comment

ID: 6957208
Dear DouglasKwong

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is:


Expert Comment

ID: 6979186
Force accepted

** Mindphaser - Community Support Moderator **

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question