Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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: http://www.experts-exchange.com/commspt/


Expert Comment

ID: 6979186
Force accepted

** Mindphaser - Community Support Moderator **

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

789 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