Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


use win32 API the print rtf and doc

Posted on 2002-04-03
Medium Priority
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
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
LVL 10

Accepted Solution

makerp earned 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

604 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